$estr = function() { return js.Boot.__string_rec(this,''); }
if(typeof haxe=='undefined') haxe = {}
haxe.BaseCode = function(base) { if( base === $_ ) return; {
	var len = base.length;
	var nbits = 1;
	while(len > 1 << nbits) nbits++;
	if(nbits > 8 || len != 1 << nbits) throw "BaseCode : base length must be a power of two.";
	this.base = base;
	this.nbits = nbits;
}}
haxe.BaseCode.__name__ = ["haxe","BaseCode"];
haxe.BaseCode.encode = function(s,base) {
	var b = new haxe.BaseCode(haxe.io.Bytes.ofString(base));
	return b.encodeString(s);
}
haxe.BaseCode.decode = function(s,base) {
	var b = new haxe.BaseCode(haxe.io.Bytes.ofString(base));
	return b.decodeString(s);
}
haxe.BaseCode.prototype.base = null;
haxe.BaseCode.prototype.nbits = null;
haxe.BaseCode.prototype.tbl = null;
haxe.BaseCode.prototype.encodeBytes = function(b) {
	var nbits = this.nbits;
	var base = this.base;
	var size = Std["int"](b.length * 8 / nbits);
	var out = haxe.io.Bytes.alloc(size + (b.length * 8 % nbits == 0?0:1));
	var buf = 0;
	var curbits = 0;
	var mask = (1 << nbits) - 1;
	var pin = 0;
	var pout = 0;
	while(pout < size) {
		while(curbits < nbits) {
			curbits += 8;
			buf <<= 8;
			buf |= b.b[pin++];
		}
		curbits -= nbits;
		out.b[pout++] = base.b[buf >> curbits & mask] & 255;
	}
	if(curbits > 0) out.b[pout++] = base.b[buf << nbits - curbits & mask] & 255;
	return out;
}
haxe.BaseCode.prototype.initTable = function() {
	var tbl = new Array();
	{
		var _g = 0;
		while(_g < 256) {
			var i = _g++;
			tbl[i] = -1;
		}
	}
	{
		var _g1 = 0, _g = this.base.length;
		while(_g1 < _g) {
			var i = _g1++;
			tbl[this.base.b[i]] = i;
		}
	}
	this.tbl = tbl;
}
haxe.BaseCode.prototype.decodeBytes = function(b) {
	var nbits = this.nbits;
	var base = this.base;
	if(this.tbl == null) this.initTable();
	var tbl = this.tbl;
	var size = b.length * nbits >> 3;
	var out = haxe.io.Bytes.alloc(size);
	var buf = 0;
	var curbits = 0;
	var pin = 0;
	var pout = 0;
	while(pout < size) {
		while(curbits < 8) {
			curbits += nbits;
			buf <<= nbits;
			var i = tbl[b.b[pin++]];
			if(i == -1) throw "BaseCode : invalid encoded char";
			buf |= i;
		}
		curbits -= 8;
		out.b[pout++] = buf >> curbits & 255 & 255;
	}
	return out;
}
haxe.BaseCode.prototype.encodeString = function(s) {
	return this.encodeBytes(haxe.io.Bytes.ofString(s)).toString();
}
haxe.BaseCode.prototype.decodeString = function(s) {
	return this.decodeBytes(haxe.io.Bytes.ofString(s)).toString();
}
haxe.BaseCode.prototype.__class__ = haxe.BaseCode;
if(typeof core=='undefined') core = {}
core.SearchResult = function(content,page) { if( content === $_ ) return; {
	this.content = content;
	this.page = page;
}}
core.SearchResult.__name__ = ["core","SearchResult"];
core.SearchResult.prototype.content = null;
core.SearchResult.prototype.page = null;
core.SearchResult.prototype.__class__ = core.SearchResult;
StringTools = function() { }
StringTools.__name__ = ["StringTools"];
StringTools.urlEncode = function(s) {
	return encodeURIComponent(s);
}
StringTools.urlDecode = function(s) {
	return decodeURIComponent(s.split("+").join(" "));
}
StringTools.htmlEscape = function(s) {
	return s.split("&").join("&amp;").split("<").join("&lt;").split(">").join("&gt;");
}
StringTools.htmlUnescape = function(s) {
	return s.split("&gt;").join(">").split("&lt;").join("<").split("&amp;").join("&");
}
StringTools.startsWith = function(s,start) {
	return s.length >= start.length && s.substr(0,start.length) == start;
}
StringTools.endsWith = function(s,end) {
	var elen = end.length;
	var slen = s.length;
	return slen >= elen && s.substr(slen - elen,elen) == end;
}
StringTools.isSpace = function(s,pos) {
	var c = s.charCodeAt(pos);
	return c >= 9 && c <= 13 || c == 32;
}
StringTools.ltrim = function(s) {
	var l = s.length;
	var r = 0;
	while(r < l && StringTools.isSpace(s,r)) {
		r++;
	}
	if(r > 0) return s.substr(r,l - r);
	else return s;
}
StringTools.rtrim = function(s) {
	var l = s.length;
	var r = 0;
	while(r < l && StringTools.isSpace(s,l - r - 1)) {
		r++;
	}
	if(r > 0) {
		return s.substr(0,l - r);
	}
	else {
		return s;
	}
}
StringTools.trim = function(s) {
	return StringTools.ltrim(StringTools.rtrim(s));
}
StringTools.rpad = function(s,c,l) {
	var sl = s.length;
	var cl = c.length;
	while(sl < l) {
		if(l - sl < cl) {
			s += c.substr(0,l - sl);
			sl = l;
		}
		else {
			s += c;
			sl += cl;
		}
	}
	return s;
}
StringTools.lpad = function(s,c,l) {
	var ns = "";
	var sl = s.length;
	if(sl >= l) return s;
	var cl = c.length;
	while(sl < l) {
		if(l - sl < cl) {
			ns += c.substr(0,l - sl);
			sl = l;
		}
		else {
			ns += c;
			sl += cl;
		}
	}
	return ns + s;
}
StringTools.replace = function(s,sub,by) {
	return s.split(sub).join(by);
}
StringTools.hex = function(n,digits) {
	var s = "";
	var hexChars = "0123456789ABCDEF";
	do {
		s = hexChars.charAt(n & 15) + s;
		n >>>= 4;
	} while(n > 0);
	if(digits != null) while(s.length < digits) s = "0" + s;
	return s;
}
StringTools.fastCodeAt = function(s,index) {
	return s.cca(index);
}
StringTools.isEOF = function(c) {
	return c != c;
}
StringTools.prototype.__class__ = StringTools;
core.HotLink = function(p) { if( p === $_ ) return; {
	this.opacity = 0.8;
	this.pageLayoutType = 0;
	this.color = "#333333";
}}
core.HotLink.__name__ = ["core","HotLink"];
core.HotLink.prototype.pageNum = null;
core.HotLink.prototype.x = null;
core.HotLink.prototype.y = null;
core.HotLink.prototype.width = null;
core.HotLink.prototype.height = null;
core.HotLink.prototype.opacity = null;
core.HotLink.prototype.color = null;
core.HotLink.prototype.destination = null;
core.HotLink.prototype.htmlText = null;
core.HotLink.prototype.dp = null;
core.HotLink.prototype.type = null;
core.HotLink.prototype.popupWidth = null;
core.HotLink.prototype.popupHeight = null;
core.HotLink.prototype.youtubeId = null;
core.HotLink.prototype.pageLayoutType = null;
core.HotLink.prototype.getDrawParams = function() {
	return RunTime.getDrawParams(this.pageLayoutType);
}
core.HotLink.prototype.loadToRect = function(ctx,x,y,w,h) {
	if(w > 0 && h > 0) {
		ctx.fillStyle = orc.utils.DrawHelper.createFillStyle(this.color,this.opacity);
		ctx.fillRect(Std["int"](x),Std["int"](y),Std["int"](w),Std["int"](h));
	}
}
core.HotLink.prototype.loadToContext2D = function(ctx) {
	if(this.dp == null) this.dp = this.getDrawParams();
	var xx = this.dp.dx + (this.x - this.dp.sx) * this.dp.scaleX();
	var yy = this.dp.dy + (this.y - this.dp.sy) * this.dp.scaleY();
	var ww = this.width * this.dp.scaleX();
	var hh = this.height * this.dp.scaleY();
	this.loadToRect(ctx,xx,yy,ww,hh);
}
core.HotLink.prototype.hitTest = function(mouseX,mouseY) {
	if(this.dp == null) this.dp = this.getDrawParams();
	var xx = this.dp.dx + (this.x - this.dp.sx) * this.dp.scaleX();
	var yy = this.dp.dy + (this.y - this.dp.sy) * this.dp.scaleY();
	var ww = this.width * this.dp.scaleX();
	var hh = this.height * this.dp.scaleY();
	var result = mouseX >= xx && mouseY >= yy && mouseX <= xx + ww && mouseY <= yy + hh;
	return result;
}
core.HotLink.prototype.click = function(popupXOffset,popupYOffset) {
	if(popupYOffset == null) popupYOffset = 0;
	if(popupXOffset == null) popupXOffset = 0;
	switch(this.type) {
	case "":{
		if(this.destination != null) {
			if(this.destination.indexOf("page:") == 0) {
				var val = this.destination.substr(5);
				var num = Std.parseInt(val);
				if(RunTime.flipBook != null) {
					RunTime.flipBook.turnToPage(num - 1);
				}
				else {
					Zoom.zoomOut(num - 1);
				}
			}
			else if(this.destination.indexOf("mailto:") == 0) {
				RunTime.logClickLink(this.destination);
				js.Lib.window.location.href = this.destination;
			}
			else {
				RunTime.logClickLink(this.destination);
				js.Lib.window.location.href = this.destination;
			}
		}
	}break;
	case "image":{
		RunTime.showPopupMaskLayer();
		RunTime.setOffset(js.Lib.document.getElementById("cvsOthers"),popupXOffset,popupYOffset);
		core.HtmlHelper.toPopupImageHtml(this,function(txt) {
			js.Lib.document.getElementById("cvsOthers").innerHTML = txt;
		});
		RunTime.logClickLink(this.destination);
	}break;
	case "video":{
		RunTime.showPopupMaskLayer();
		RunTime.setOffset(js.Lib.document.getElementById("cvsOthers"),popupXOffset,popupYOffset);
		js.Lib.document.getElementById("cvsOthers").innerHTML = core.HtmlHelper.toPopupVideoHtml(this);
		RunTime.playVideo();
		RunTime.logVideoView(this.destination,this.youtubeId);
	}break;
	case "audio":{
		js.Lib.document.getElementById("cvsAudio").innerHTML = core.HtmlHelper.toPopupAudioHtml(this);
		RunTime.logAudioView(this.destination);
		RunTime.playAudio();
	}break;
	case "message":{
		RunTime.showPopupMaskLayer();
		RunTime.setOffset(js.Lib.document.getElementById("cvsOthers"),popupXOffset,popupYOffset);
		js.Lib.document.getElementById("cvsOthers").innerHTML = core.HtmlHelper.toPopupHtml(this);
	}break;
	case "message-hover":{
		RunTime.showPopupMaskLayer();
		RunTime.setOffset(js.Lib.document.getElementById("cvsOthers"),popupXOffset,popupYOffset);
		js.Lib.document.getElementById("cvsOthers").innerHTML = core.HtmlHelper.toPopupHtml(this);
	}break;
	}
}
core.HotLink.prototype.__class__ = core.HotLink;
EReg = function(r,opt) { if( r === $_ ) return; {
	opt = opt.split("u").join("");
	this.r = new RegExp(r,opt);
}}
EReg.__name__ = ["EReg"];
EReg.prototype.r = null;
EReg.prototype.match = function(s) {
	this.r.m = this.r.exec(s);
	this.r.s = s;
	this.r.l = RegExp.leftContext;
	this.r.r = RegExp.rightContext;
	return this.r.m != null;
}
EReg.prototype.matched = function(n) {
	return this.r.m != null && n >= 0 && n < this.r.m.length?this.r.m[n]:(function($this) {
		var $r;
		throw "EReg::matched";
		return $r;
	}(this));
}
EReg.prototype.matchedLeft = function() {
	if(this.r.m == null) throw "No string matched";
	if(this.r.l == null) return this.r.s.substr(0,this.r.m.index);
	return this.r.l;
}
EReg.prototype.matchedRight = function() {
	if(this.r.m == null) throw "No string matched";
	if(this.r.r == null) {
		var sz = this.r.m.index + this.r.m[0].length;
		return this.r.s.substr(sz,this.r.s.length - sz);
	}
	return this.r.r;
}
EReg.prototype.matchedPos = function() {
	if(this.r.m == null) throw "No string matched";
	return { pos : this.r.m.index, len : this.r.m[0].length};
}
EReg.prototype.split = function(s) {
	var d = "#__delim__#";
	return s.replace(this.r,d).split(d);
}
EReg.prototype.replace = function(s,by) {
	return s.replace(this.r,by);
}
EReg.prototype.customReplace = function(s,f) {
	var buf = new StringBuf();
	while(true) {
		if(!this.match(s)) break;
		buf.b[buf.b.length] = this.matchedLeft();
		buf.b[buf.b.length] = f(this);
		s = this.matchedRight();
	}
	buf.b[buf.b.length] = s;
	return buf.b.join("");
}
EReg.prototype.__class__ = EReg;
Xml = function(p) { if( p === $_ ) return; {
	null;
}}
Xml.__name__ = ["Xml"];
Xml.Element = null;
Xml.PCData = null;
Xml.CData = null;
Xml.Comment = null;
Xml.DocType = null;
Xml.Prolog = null;
Xml.Document = null;
Xml.parse = function(str) {
	var rules = [Xml.enode,Xml.epcdata,Xml.eend,Xml.ecdata,Xml.edoctype,Xml.ecomment,Xml.eprolog];
	var nrules = rules.length;
	var current = Xml.createDocument();
	var stack = new List();
	while(str.length > 0) {
		var i = 0;
		try {
			while(i < nrules) {
				var r = rules[i];
				if(r.match(str)) {
					switch(i) {
					case 0:{
						var x = Xml.createElement(r.matched(1));
						current.addChild(x);
						str = r.matchedRight();
						while(Xml.eattribute.match(str)) {
							x.set(Xml.eattribute.matched(1),Xml.eattribute.matched(3));
							str = Xml.eattribute.matchedRight();
						}
						if(!Xml.eclose.match(str)) {
							i = nrules;
							throw "__break__";
						}
						if(Xml.eclose.matched(1) == ">") {
							stack.push(current);
							current = x;
						}
						str = Xml.eclose.matchedRight();
					}break;
					case 1:{
						var x = Xml.createPCData(r.matched(0));
						current.addChild(x);
						str = r.matchedRight();
					}break;
					case 2:{
						if(current._children != null && current._children.length == 0) {
							var e = Xml.createPCData("");
							current.addChild(e);
						}
						else null;
						if(r.matched(1) != current._nodeName || stack.isEmpty()) {
							i = nrules;
							throw "__break__";
						}
						else null;
						current = stack.pop();
						str = r.matchedRight();
					}break;
					case 3:{
						str = r.matchedRight();
						if(!Xml.ecdata_end.match(str)) throw "End of CDATA section not found";
						var x = Xml.createCData(Xml.ecdata_end.matchedLeft());
						current.addChild(x);
						str = Xml.ecdata_end.matchedRight();
					}break;
					case 4:{
						var pos = 0;
						var count = 0;
						var old = str;
						try {
							while(true) {
								if(!Xml.edoctype_elt.match(str)) throw "End of DOCTYPE section not found";
								var p = Xml.edoctype_elt.matchedPos();
								pos += p.pos + p.len;
								str = Xml.edoctype_elt.matchedRight();
								switch(Xml.edoctype_elt.matched(0)) {
								case "[":{
									count++;
								}break;
								case "]":{
									count--;
									if(count < 0) throw "Invalid ] found in DOCTYPE declaration";
								}break;
								default:{
									if(count == 0) throw "__break__";
								}break;
								}
							}
						} catch( e ) { if( e != "__break__" ) throw e; }
						var x = Xml.createDocType(old.substr(10,pos - 11));
						current.addChild(x);
					}break;
					case 5:{
						if(!Xml.ecomment_end.match(str)) throw "Unclosed Comment";
						var p = Xml.ecomment_end.matchedPos();
						var x = Xml.createComment(str.substr(4,p.pos + p.len - 7));
						current.addChild(x);
						str = Xml.ecomment_end.matchedRight();
					}break;
					case 6:{
						var prolog = r.matched(0);
						var x = Xml.createProlog(prolog.substr(2,prolog.length - 4));
						current.addChild(x);
						str = r.matchedRight();
					}break;
					}
					throw "__break__";
				}
				i += 1;
			}
		} catch( e ) { if( e != "__break__" ) throw e; }
		if(i == nrules) {
			if(str.length > 10) throw "Xml parse error : Unexpected " + str.substr(0,10) + "...";
			else throw "Xml parse error : Unexpected " + str;
		}
	}
	if(!stack.isEmpty()) throw "Xml parse error : Unclosed " + stack.last().getNodeName();
	return current;
}
Xml.createElement = function(name) {
	var r = new Xml();
	r.nodeType = Xml.Element;
	r._children = new Array();
	r._attributes = new Hash();
	r.setNodeName(name);
	return r;
}
Xml.createPCData = function(data) {
	var r = new Xml();
	r.nodeType = Xml.PCData;
	r.setNodeValue(data);
	return r;
}
Xml.createCData = function(data) {
	var r = new Xml();
	r.nodeType = Xml.CData;
	r.setNodeValue(data);
	return r;
}
Xml.createComment = function(data) {
	var r = new Xml();
	r.nodeType = Xml.Comment;
	r.setNodeValue(data);
	return r;
}
Xml.createDocType = function(data) {
	var r = new Xml();
	r.nodeType = Xml.DocType;
	r.setNodeValue(data);
	return r;
}
Xml.createProlog = function(data) {
	var r = new Xml();
	r.nodeType = Xml.Prolog;
	r.setNodeValue(data);
	return r;
}
Xml.createDocument = function() {
	var r = new Xml();
	r.nodeType = Xml.Document;
	r._children = new Array();
	return r;
}
Xml.prototype.nodeType = null;
Xml.prototype.nodeName = null;
Xml.prototype.nodeValue = null;
Xml.prototype.parent = null;
Xml.prototype._nodeName = null;
Xml.prototype._nodeValue = null;
Xml.prototype._attributes = null;
Xml.prototype._children = null;
Xml.prototype._parent = null;
Xml.prototype.getNodeName = function() {
	if(this.nodeType != Xml.Element) throw "bad nodeType";
	return this._nodeName;
}
Xml.prototype.setNodeName = function(n) {
	if(this.nodeType != Xml.Element) throw "bad nodeType";
	return this._nodeName = n;
}
Xml.prototype.getNodeValue = function() {
	if(this.nodeType == Xml.Element || this.nodeType == Xml.Document) throw "bad nodeType";
	return this._nodeValue;
}
Xml.prototype.setNodeValue = function(v) {
	if(this.nodeType == Xml.Element || this.nodeType == Xml.Document) throw "bad nodeType";
	return this._nodeValue = v;
}
Xml.prototype.getParent = function() {
	return this._parent;
}
Xml.prototype.get = function(att) {
	if(this.nodeType != Xml.Element) throw "bad nodeType";
	return this._attributes.get(att);
}
Xml.prototype.set = function(att,value) {
	if(this.nodeType != Xml.Element) throw "bad nodeType";
	this._attributes.set(att,value);
}
Xml.prototype.remove = function(att) {
	if(this.nodeType != Xml.Element) throw "bad nodeType";
	this._attributes.remove(att);
}
Xml.prototype.exists = function(att) {
	if(this.nodeType != Xml.Element) throw "bad nodeType";
	return this._attributes.exists(att);
}
Xml.prototype.attributes = function() {
	if(this.nodeType != Xml.Element) throw "bad nodeType";
	return this._attributes.keys();
}
Xml.prototype.iterator = function() {
	if(this._children == null) throw "bad nodetype";
	return { cur : 0, x : this._children, hasNext : function() {
		return this.cur < this.x.length;
	}, next : function() {
		return this.x[this.cur++];
	}};
}
Xml.prototype.elements = function() {
	if(this._children == null) throw "bad nodetype";
	return { cur : 0, x : this._children, hasNext : function() {
		var k = this.cur;
		var l = this.x.length;
		while(k < l) {
			if(this.x[k].nodeType == Xml.Element) break;
			k += 1;
		}
		this.cur = k;
		return k < l;
	}, next : function() {
		var k = this.cur;
		var l = this.x.length;
		while(k < l) {
			var n = this.x[k];
			k += 1;
			if(n.nodeType == Xml.Element) {
				this.cur = k;
				return n;
			}
		}
		return null;
	}};
}
Xml.prototype.elementsNamed = function(name) {
	if(this._children == null) throw "bad nodetype";
	return { cur : 0, x : this._children, hasNext : function() {
		var k = this.cur;
		var l = this.x.length;
		while(k < l) {
			var n = this.x[k];
			if(n.nodeType == Xml.Element && n._nodeName == name) break;
			k++;
		}
		this.cur = k;
		return k < l;
	}, next : function() {
		var k = this.cur;
		var l = this.x.length;
		while(k < l) {
			var n = this.x[k];
			k++;
			if(n.nodeType == Xml.Element && n._nodeName == name) {
				this.cur = k;
				return n;
			}
		}
		return null;
	}};
}
Xml.prototype.firstChild = function() {
	if(this._children == null) throw "bad nodetype";
	return this._children[0];
}
Xml.prototype.firstElement = function() {
	if(this._children == null) throw "bad nodetype";
	var cur = 0;
	var l = this._children.length;
	while(cur < l) {
		var n = this._children[cur];
		if(n.nodeType == Xml.Element) return n;
		cur++;
	}
	return null;
}
Xml.prototype.addChild = function(x) {
	if(this._children == null) throw "bad nodetype";
	if(x._parent != null) x._parent._children.remove(x);
	x._parent = this;
	this._children.push(x);
}
Xml.prototype.removeChild = function(x) {
	if(this._children == null) throw "bad nodetype";
	var b = this._children.remove(x);
	if(b) x._parent = null;
	return b;
}
Xml.prototype.insertChild = function(x,pos) {
	if(this._children == null) throw "bad nodetype";
	if(x._parent != null) x._parent._children.remove(x);
	x._parent = this;
	this._children.insert(pos,x);
}
Xml.prototype.toString = function() {
	if(this.nodeType == Xml.PCData) return this._nodeValue;
	if(this.nodeType == Xml.CData) return "<![CDATA[" + this._nodeValue + "]]>";
	if(this.nodeType == Xml.Comment) return "<!--" + this._nodeValue + "-->";
	if(this.nodeType == Xml.DocType) return "<!DOCTYPE " + this._nodeValue + ">";
	if(this.nodeType == Xml.Prolog) return "<?" + this._nodeValue + "?>";
	var s = new StringBuf();
	if(this.nodeType == Xml.Element) {
		s.b[s.b.length] = "<";
		s.b[s.b.length] = this._nodeName;
		{ var $it0 = this._attributes.keys();
		while( $it0.hasNext() ) { var k = $it0.next();
		{
			s.b[s.b.length] = " ";
			s.b[s.b.length] = k;
			s.b[s.b.length] = "=\"";
			s.b[s.b.length] = this._attributes.get(k);
			s.b[s.b.length] = "\"";
		}
		}}
		if(this._children.length == 0) {
			s.b[s.b.length] = "/>";
			return s.b.join("");
		}
		s.b[s.b.length] = ">";
	}
	{ var $it1 = this.iterator();
	while( $it1.hasNext() ) { var x = $it1.next();
	s.b[s.b.length] = x.toString();
	}}
	if(this.nodeType == Xml.Element) {
		s.b[s.b.length] = "</";
		s.b[s.b.length] = this._nodeName;
		s.b[s.b.length] = ">";
	}
	return s.b.join("");
}
Xml.prototype.__class__ = Xml;
haxe.Log = function() { }
haxe.Log.__name__ = ["haxe","Log"];
haxe.Log.trace = function(v,infos) {
	js.Boot.__trace(v,infos);
}
haxe.Log.clear = function() {
	js.Boot.__clear_trace();
}
haxe.Log.prototype.__class__ = haxe.Log;
if(typeof orc=='undefined') orc = {}
if(!orc.utils) orc.utils = {}
orc.utils.ImageMetricHelper = function(imgWidth,imgHeight) { if( imgWidth === $_ ) return; {
	this.width = imgWidth;
	this.height = imgHeight;
	this.diagonalLineTheta = Math.atan2(this.width,this.height);
	this.diagonalLineLength = Math.sqrt(this.width * this.width + this.height * this.height);
}}
orc.utils.ImageMetricHelper.__name__ = ["orc","utils","ImageMetricHelper"];
orc.utils.ImageMetricHelper.prototype.diagonalLineTheta = null;
orc.utils.ImageMetricHelper.prototype.diagonalLineLength = null;
orc.utils.ImageMetricHelper.prototype.width = null;
orc.utils.ImageMetricHelper.prototype.height = null;
orc.utils.ImageMetricHelper.prototype.getMaxFitScale = function(width,height,rotation) {
	if(rotation == null) rotation = 0;
	var scaleX;
	var scaleY;
	if(rotation == 0 || rotation == 180) {
		scaleX = width / this.width;
		scaleY = height / this.height;
	}
	else {
		var r = Math.PI * rotation / 180;
		var t0 = this.diagonalLineTheta + r;
		var w0 = Math.abs(this.diagonalLineLength * Math.sin(t0));
		var h0 = Math.abs(this.diagonalLineLength * Math.cos(t0));
		var t1 = -this.diagonalLineTheta + r;
		var w1 = Math.abs(this.diagonalLineLength * Math.sin(t1));
		var h1 = Math.abs(this.diagonalLineLength * Math.cos(t1));
		var w = Math.max(w0,w1);
		var h = Math.max(h0,h1);
		scaleX = width / w;
		scaleY = height / h;
	}
	return Math.min(scaleX,scaleY);
}
orc.utils.ImageMetricHelper.prototype.__class__ = orc.utils.ImageMetricHelper;
core.PagePair = function(i) { if( i === $_ ) return; {
	if(i < 0 || i >= RunTime.book.pages.length) return;
	this.currentPageNum = i;
	if(i == 0) {
		this.rightPage = RunTime.book.pages[i];
		this.rightPage.isDoublePageMode = true;
		this.rightPage.pageOffset = 0;
		this.rightPage.drawParams = RunTime.getDrawParams(1);
	}
	else if(i == RunTime.book.pages.length - 1 && i % 2 == 1) {
		this.leftPage = RunTime.book.pages[i];
		this.leftPage.isDoublePageMode = true;
		this.leftPage.pageOffset = 0;
		this.leftPage.drawParams = RunTime.getDrawParams(-1);
	}
	else {
		var right = i + 1 - (i + 1) % 2;
		var left = right - 1;
		this.leftPage = RunTime.book.pages[left];
		this.rightPage = RunTime.book.pages[right];
		this.leftPage.isDoublePageMode = true;
		this.rightPage.isDoublePageMode = true;
		this.leftPage.pageOffset = 0;
		this.rightPage.pageOffset = 0;
		this.leftPage.drawParams = RunTime.getDrawParams(-1);
		this.rightPage.drawParams = RunTime.getDrawParams(1);
	}
}}
core.PagePair.__name__ = ["core","PagePair"];
core.PagePair.prototype.leftPage = null;
core.PagePair.prototype.rightPage = null;
core.PagePair.prototype.currentPageNum = null;
core.PagePair.prototype.match = function(pageNum) {
	if(this.leftPage != null) {
		if(this.leftPage.num == pageNum) return -1;
	}
	if(this.rightPage != null) {
		if(this.rightPage.num == pageNum) return 1;
	}
	return 0;
}
core.PagePair.prototype.getNumInDoubleMode = function() {
	if(this.leftPage != null) return this.leftPage.numInDoubleMode;
	else if(this.rightPage != null) return this.rightPage.numInDoubleMode;
	else return -1;
}
core.PagePair.prototype.__class__ = core.PagePair;
orc.utils.Util = function() { }
orc.utils.Util.__name__ = ["orc","utils","Util"];
orc.utils.Util.request = function(url,call) {
	var http = new haxe.Http(url);
	http.onData = call;
	http.request(false);
}
orc.utils.Util.getUrlParam = function(key) {
	var params = orc.utils.Util.getUrlParams();
	{
		var _g = 0;
		while(_g < params.length) {
			var param = params[_g];
			++_g;
			var p = param;
			if(p.key == key) {
				return p.value;
			}
		}
	}
	return "";
}
orc.utils.Util.getUrlParams = function() {
	var url = js.Lib.window.location.href;
	var results = new Array();
	var index = url.indexOf("?");
	if(index > 0) {
		var params = url.substr(index + 1);
		var lines = params.split("&");
		{
			var _g = 0;
			while(_g < lines.length) {
				var line = lines[_g];
				++_g;
				var terms = line.split("=");
				if(terms.length == 2) {
					var val = new orc.utils.UrlParam();
					val.key = terms[0];
					val.value = terms[1];
					results.push(val);
				}
			}
		}
	}
	return results;
}
orc.utils.Util.getXmlChilds = function(xml) {
	var i = xml.elements();
	var list = new Array();
	while(i.hasNext() == true) {
		var node = i.next();
		list.push(node);
	}
	return list;
}
orc.utils.Util.searchPos = function(txt,keyword) {
	var list = [];
	var index = -1;
	while(true) {
		var from = 0;
		if(index != -1) {
			from = index + keyword.length;
			if(from < 0) from = 0;
		}
		index = txt.indexOf(keyword,from);
		if(index > -1 && index + keyword.length <= txt.length) {
			list.push(index);
		}
		else {
			break;
		}
	}
	return list;
}
orc.utils.Util.createSearchResults = function(txt,keyword,posList,page) {
	var results = [];
	var maxChars = 50;
	var coloredWord = "<font color='#FF0000'>" + keyword + "</font>";
	{
		var _g1 = 0, _g = posList.length;
		while(_g1 < _g) {
			var i = _g1++;
			var index = posList[i];
			var r = new core.SearchResult("",page);
			var offset = index;
			if(txt.length < maxChars) {
				r.content = txt;
			}
			else {
				var from = Std["int"](index - Math.max(0,maxChars - keyword.length) / 2);
				if(from < 0) from = 0;
				r.content = txt.substr(from,maxChars);
				offset = index - from;
				if(from + maxChars < txt.length) {
					r.content += " ...";
				}
				if(from > 0) {
					r.content = "... " + r.content;
					offset += 4;
				}
			}
			r.content = r.content.substr(0,offset) + "<font color='#FF0000'>" + r.content.substr(offset,keyword.length) + "</font>" + r.content.substr(offset + keyword.length);
			results.push(r);
		}
	}
	return results;
}
orc.utils.Util.prototype.__class__ = orc.utils.Util;
StringBuf = function(p) { if( p === $_ ) return; {
	this.b = new Array();
}}
StringBuf.__name__ = ["StringBuf"];
StringBuf.prototype.add = function(x) {
	this.b[this.b.length] = x;
}
StringBuf.prototype.addSub = function(s,pos,len) {
	this.b[this.b.length] = s.substr(pos,len);
}
StringBuf.prototype.addChar = function(c) {
	this.b[this.b.length] = String.fromCharCode(c);
}
StringBuf.prototype.toString = function() {
	return this.b.join("");
}
StringBuf.prototype.b = null;
StringBuf.prototype.__class__ = StringBuf;
core.Page = function(p) { if( p === $_ ) return; {
	this.visible = true;
	this.pageOffset = 0;
}}
core.Page.__name__ = ["core","Page"];
core.Page.prototype.urlPage = null;
core.Page.prototype.urlThumb = null;
core.Page.prototype.urlFullPage = null;
core.Page.prototype.id = null;
core.Page.prototype.num = null;
core.Page.prototype.numInDoubleMode = null;
core.Page.prototype.turnRightCallback = null;
core.Page.prototype.turnLeftCallback = null;
core.Page.prototype.drawParams = null;
core.Page.prototype.pageOffset = null;
core.Page.prototype.isDoublePageMode = null;
core.Page.prototype.ctx = null;
core.Page.prototype._imagePage = null;
core.Page.prototype._imageData = null;
core.Page.prototype.imagePage = null;
core.Page.prototype.loaded = null;
core.Page.prototype.visible = null;
core.Page.prototype.bookContext = null;
core.Page.prototype.content = null;
core.Page.prototype.contentLowerCase = null;
core.Page.prototype.onLoadImage = function() {
	this.loaded = true;
	this.draw();
	if(RunTime.flipBook.currentPageNum == null || RunTime.flipBook.currentPageNum == this.num) {
		RunTime.flipBook.loadCtxHotlinks();
		RunTime.flipBook.bookContext.render();
	}
}
core.Page.prototype.getImagePage = function() {
	if(this._imagePage != null) return this._imagePage;
	var img = new Image();
	img.src = this.urlPage;
	img.onload = $closure(this,"onLoadImage");
	this._imagePage = img;
	return this._imagePage;
}
core.Page.prototype.clearCallback = function() {
	this.turnLeftCallback = null;
	this.turnRightCallback = null;
}
core.Page.prototype.onMouseClick = function(e) {
	if(e.localX > this.getImagePage().width * 0.5) {
		if(this.turnRightCallback != null) {
			this.turnRightCallback();
		}
	}
	else {
		if(this.turnLeftCallback != null) {
			this.turnLeftCallback();
		}
	}
}
core.Page.prototype.loadToContext2D = function(ctx) {
	this.ctx = ctx;
	if(this._imagePage == null) {
		this.getImagePage();
	}
	if(this.loaded == true) {
		this.draw();
	}
}
core.Page.prototype.draw = function() {
	if(this.ctx == null) return;
	if(this.drawParams == null) return;
	if(this.visible == false) return;
	var offset = this.pageOffset;
	if(this.bookContext != null) {
		offset += this.bookContext.pageOffset;
	}
	if(offset > -1.001 && offset < -1) offset = -1;
	if(offset > 1 && offset < 1.001) offset = 1;
	if(offset <= -1 || offset >= 1) return;
	this.drawImageCore(offset);
}
core.Page.prototype.drawImageCore = function(offset) {
	var dp = this.drawParams;
	if(dp == null || dp.dw < 2) return;
	if(offset == 0) {
		this.clipImage(this.ctx,this._imagePage,dp.sx,dp.sy,dp.sw,dp.sh,dp.dx,dp.dy,dp.dw,dp.dh);
		if(this._imageData == null) null;
	}
	else if(offset > 0) {
		this.clipImage(this.ctx,this._imagePage,dp.sx,dp.sy,dp.sw * (1 - offset),dp.sh,dp.dx + dp.dw * offset,dp.dy,dp.dw * (1 - offset),dp.dh);
	}
	else {
		offset = -offset;
		this.clipImage(this.ctx,this._imagePage,dp.sx + offset * dp.sw,dp.sy,dp.sw * (1 - offset),dp.sh,dp.dx,dp.dy,dp.dw * (1 - offset),dp.dh);
	}
}
core.Page.prototype.clipImage = function(ctx,img,sx,sy,sw,sh,dx,dy,dw,dh) {
	var pw = RunTime.book.pageWidth;
	var ph = RunTime.book.pageHeight;
	var rw = img.width;
	var rh = img.height;
	var scaleX = rw / pw;
	var scaleY = rh / ph;
	sx = sx * scaleX;
	sy = sy * scaleY;
	sw = sw * scaleX;
	sh = sh * scaleY;
	if(sx < 0) sx = 0;
	if(sy < 0) sy = 0;
	if(sx + sw > img.width) {
		sw = img.width - sx;
	}
	if(sy + sh > img.height) {
		sh = img.height - sy;
	}
	if(sx >= img.width || sy >= img.height) return;
	if(sw < 1 || sh < 1) return;
	ctx.drawImage(img,sx,sy,sw,sh,dx,dy,dw,dh);
}
core.Page.prototype.__class__ = core.Page;
core.Tweener = function(p) { if( p === $_ ) return; {
	this.count = 0;
	this.maxCount = 0;
}}
core.Tweener.__name__ = ["core","Tweener"];
core.Tweener.prototype.count = null;
core.Tweener.prototype.maxCount = null;
core.Tweener.prototype.onChange = null;
core.Tweener.prototype.start = function(max) {
	if(max == null) max = 1;
	this.maxCount = max;
	this.count = 0;
	this.run();
}
core.Tweener.prototype.stop = function() {
	this.maxCount = this.count;
}
core.Tweener.prototype.run = function() {
	if(this.count >= this.maxCount) return;
	haxe.Timer.delay($closure(this,"onChangeInvoke"),20);
}
core.Tweener.prototype.onChangeInvoke = function() {
	this.count++;
	if(this.onChange == null) return;
	if(this.count > this.maxCount) return;
	this.onChange(this.count);
	this.run();
}
core.Tweener.prototype.__class__ = core.Tweener;
core.VideoInfo = function(p) { if( p === $_ ) return; {
	this.pageLayoutType = 0;
	this.youtubeId = "";
	this.url = "";
}}
core.VideoInfo.__name__ = ["core","VideoInfo"];
core.VideoInfo.prototype.pageNum = null;
core.VideoInfo.prototype.x = null;
core.VideoInfo.prototype.y = null;
core.VideoInfo.prototype.width = null;
core.VideoInfo.prototype.height = null;
core.VideoInfo.prototype.autoPlay = null;
core.VideoInfo.prototype.showControl = null;
core.VideoInfo.prototype.autoRepeat = null;
core.VideoInfo.prototype.url = null;
core.VideoInfo.prototype.youtubeId = null;
core.VideoInfo.prototype.dp = null;
core.VideoInfo.prototype.pageLayoutType = null;
core.VideoInfo.prototype.getDrawParams = function() {
	return RunTime.getDrawParams(this.pageLayoutType);
}
core.VideoInfo.prototype.__class__ = core.VideoInfo;
core.HtmlHelper = function() { }
core.HtmlHelper.__name__ = ["core","HtmlHelper"];
core.HtmlHelper.toContentsHtml = function(xml) {
	var roots = orc.utils.Util.getXmlChilds(xml);
	if(roots.length != 1) return "";
	var root = roots[0];
	var childs = orc.utils.Util.getXmlChilds(root);
	var s = "";
	if(childs.length > 0) {
		{
			var _g1 = 0, _g = childs.length;
			while(_g1 < _g) {
				var i = _g1++;
				s += core.HtmlHelper.toContentsNodeHtml(childs[i]);
			}
		}
	}
	return s;
}
core.HtmlHelper.toContentsNodeHtml = function(xml) {
	var childs = orc.utils.Util.getXmlChilds(xml);
	var s = "";
	s += "<ul>";
	s += "<li>";
	s += core.HtmlHelper.toContentsNodeHtmlCore(xml);
	s += "</li>";
	if(childs.length > 0) {
		s += "<ul>";
		{
			var _g1 = 0, _g = childs.length;
			while(_g1 < _g) {
				var i = _g1++;
				s += core.HtmlHelper.toContentsNodeHtml(childs[i]);
			}
		}
		s += "</ul>";
	}
	s += "</ul>";
	return s;
}
core.HtmlHelper.toContentsNodeHtmlCore = function(xml) {
	var title = xml.get("title");
	var page = xml.get("page");
	var pageVal = 0;
	if(page != null && page != "") {
		pageVal = Std.parseInt(page);
		page = Std.string(pageVal);
	}
	return "<span onclick=\"gotoPage(" + page + ");\">" + title + "</span>";
}
core.HtmlHelper.toThumbsHtml = function(pages) {
	var s = "";
	{
		var _g1 = 0, _g = pages.length;
		while(_g1 < _g) {
			var i = _g1++;
			var page = pages[i];
			s += core.HtmlHelper.toThumbsNodeHtml(page);
		}
	}
	return s;
}
core.HtmlHelper.toThumbsNodeHtml = function(page) {
	return "<img class=\"thumb\" src=\"" + page.urlThumb + "\" onclick=\"gotoPage(" + page.num + "); \" />";
}
core.HtmlHelper.toSearchHtml = function() {
	return RunTime.searchHtmlCache;
}
core.HtmlHelper.toSearchResultHtml = function(results) {
	var s = "";
	s += "<table>";
	{
		var _g1 = 0, _g = results.length;
		while(_g1 < _g) {
			var i = _g1++;
			var item = results[i];
			s += "<tr onclick=\"gotoPage(" + Std.string(item.page - 1) + ")\">";
			s += "<td width=\"40px\" class=\"colPage\">";
			s += "P" + Std.string(item.page);
			s += "</td>";
			s += "<td class=\"colContent\">";
			s += item.content;
			s += "</td>";
			s += "</tr>";
		}
	}
	s += "</table>";
	return s;
}
core.HtmlHelper.toVideoHtml = function(video) {
	var dp = video.getDrawParams();
	var xx = dp.dx + (video.x - dp.sx) * (dp.dw / dp.sw);
	var yy = dp.dy + (video.y - dp.sy) * (dp.dh / dp.sh);
	var ww = video.width * (dp.dw / dp.sw);
	var hh = video.height * (dp.dh / dp.sh);
	if(video.youtubeId != null && video.youtubeId != "") {
		return core.HtmlHelper.toRectYoutubeVideoHtml(video,xx,yy,ww,hh);
	}
	else {
		return core.HtmlHelper.toRectVideoHtml(video,xx,yy,ww,hh);
	}
}
core.HtmlHelper.toRectVideoHtml = function(video,xx,yy,ww,hh) {
	var loop = video.autoRepeat?"loop":"";
	var s = "";
	s += "<div style=\"position:absolute;padding-left:" + Std.string(Math.round(xx)) + "px;padding-top:" + Std.string(Math.round(yy)) + "px;\">";
	s += "<video class=\"video-js\" src=\"" + video.url + "\" width=\"" + Std.string(Math.round(ww)) + "\" height=\"" + Std.string(Math.round(hh)) + "\" controls autoplay preload onloadeddata='RunTime.logVideoView(\"" + video.url + "\", \"" + video.youtubeId + "\")' " + loop + " >";
	s += "</video>";
	s += "</div>";
	return s;
}
core.HtmlHelper.toRectYoutubeVideoHtml = function(video,xx,yy,ww,hh) {
	var s = "";
	s += "<div style=\"position:absolute;padding-left:" + Std.string(Math.round(xx)) + "px;padding-top:" + Std.string(Math.round(yy)) + "px;\">";
	s += "<iframe frameborder=\"0\" type=\"text/html\"" + "\" width=\"" + Std.string(Math.round(ww)) + "\" height=\"" + Std.string(Math.round(hh)) + "\"" + " src=\"http://www.youtube.com/embed/" + video.youtubeId + "?controls=1&amp;antoplay=1&amp;enablejsapi=1\">";
	s += "</iframe>";
	s += "</div>";
	return s;
}
core.HtmlHelper.toPopupImageHtml = function(item,success) {
	var w = Std["int"](RunTime.clientWidth * 0.9);
	var h = Std["int"](RunTime.clientHeight * 0.9);
	if(item.popupWidth != null && item.popupHeight != null) {
		w = item.popupWidth;
		h = item.popupHeight;
	}
	else {
		var img = null;
		var onload = function() {
			item.popupWidth = img.image.width;
			item.popupHeight = img.image.height;
			core.HtmlHelper.toPopupImageHtml(item,success);
		}
		img = new core.Html5Image(item.destination,onload);
		return;
	}
	var helper = new orc.utils.ImageMetricHelper(w,h);
	var scale = helper.getMaxFitScale(RunTime.clientWidth * 0.9,RunTime.clientHeight * 0.9);
	h = Std["int"](h * scale);
	w = Std["int"](w * scale);
	var left = Std["int"]((RunTime.clientWidth - w) / 2);
	var top = Std["int"]((RunTime.clientHeight - h) / 2);
	var s = "";
	if(item.popupWidth != null && item.popupHeight != null) {
		s = "";
		s += "<div style=\"position:absolute; left:" + Std.string(left) + "px; top:" + Std.string(top) + "px; width:" + Std.string(w) + "px; height:" + Std.string(h) + "px; background-color:#ffffff; \">";
		s += "<img src=\"" + item.destination + "\" style=\"width:" + Std.string(w) + "px;height:" + Std.string(h) + "px;\" />";
		s += "<img width=\"24\" height=\"24\" src=\"content/images/close.png\" onclick=\"clearPopupContents();\" style=\"position:absolute;right:-12px;top:-12px;\" />";
		s += "</div>";
	}
	else {
		s = "";
		s += "<div style=\"position:absolute; left:" + Std.string(left) + "px; top:" + Std.string(top) + "px; width:" + Std.string(w) + "px; height:" + Std.string(h) + "px; \">";
		s += "<div style=\"margin:0 auto; \">";
		s += "<img src=\"" + item.destination + "\" style=\"max-width:" + Std.string(w) + "px;max-height:" + Std.string(h) + "px;\" />";
		s += "<img width=\"24\" height=\"24\" src=\"content/images/close.png\" onclick=\"clearPopupContents();\" style=\"position:absolute;right:-12px;top:-12px;\" />";
		s += "</div>";
		s += "</div>";
	}
	if(success != null) {
		success(s);
	}
}
core.HtmlHelper.toPopupVideoHtml = function(item) {
	var w = 600;
	var h = 480;
	if(item.popupWidth != null && item.popupHeight != null) {
		w = item.popupWidth;
		h = item.popupHeight;
	}
	var left = Std["int"]((RunTime.clientWidth - w) / 2);
	var top = Std["int"]((RunTime.clientHeight - h) / 2);
	var s = "";
	s += "<div style=\"position:absolute; left:" + Std.string(left) + "px; top:" + Std.string(top) + "px; width:" + Std.string(w) + "px; height:" + Std.string(h) + "px; background-color:#ffffff; \">";
	if(item.youtubeId == null || item.youtubeId == "") {
		s += "<video class=\"video-js\" src=\"" + item.destination + "\" width=\"" + Std.string(Math.round(w)) + "\" height=\"" + Std.string(Math.round(h)) + "\" controls autoplay preload onloadstart='this.play()' >";
		s += "</video>";
	}
	else {
		s += "<div style=\"position:absolute;padding-left:0px;padding-top:0px;\">";
		s += "<iframe frameborder=\"0\" type=\"text/html\"" + "\" width=\"" + Std.string(Math.round(w)) + "\" height=\"" + Std.string(Math.round(h)) + "\"" + " src=\"http://www.youtube.com/embed/" + item.youtubeId + "?controls=1&amp;antoplay=1&amp;enablejsapi=1\">";
		s += "</iframe>";
		s += "</div>";
	}
	s += "<img width=\"24\" height=\"24\" src=\"content/images/close.png\" onclick=\"clearPopupContents();\" style=\"position:absolute;right:-12px;top:-12px;\" />";
	s += "</div>";
	return s;
}
core.HtmlHelper.toPopupAudioHtml = function(item) {
	var w = 200;
	var h = 40;
	var left = 20;
	var top = 20;
	var s = "";
	s += "<div style=\"position:absolute; left:" + Std.string(left) + "px; top:" + Std.string(top) + "px; width:" + Std.string(w) + "px; height:" + Std.string(h) + "px; \">";
	s += "<audio class=\"video-js\" src=\"" + item.destination + "\" width=\"" + Std.string(Math.round(w)) + "\" height=\"" + Std.string(Math.round(h)) + "\" controls autoplay >";
	s += "</audio>";
	s += "<img width=\"24\" height=\"24\" src=\"content/images/close.png\" onclick=\"clearAudio();\" style=\"position:absolute;right:-12px;top:-12px;\" />";
	s += "</div>";
	return s;
}
core.HtmlHelper.toPopupHtml = function(item) {
	var w = 600;
	var h = 480;
	if(item.popupWidth != null && item.popupHeight != null) {
		w = item.popupWidth;
		h = item.popupHeight;
	}
	var left = Std["int"]((RunTime.clientWidth - w) / 2);
	var top = Std["int"]((RunTime.clientHeight - h) / 2);
	var s = "";
	s += "<div style=\"position:absolute; left:" + Std.string(left) + "px; top:" + Std.string(top) + "px; width:" + Std.string(w) + "px; height:" + Std.string(h) + "px; background-color:#ffffff; text-align:left; \">";
	s += item.htmlText;
	s += "<img width=\"24\" height=\"24\" src=\"content/images/close.png\" onclick=\"clearPopupContents();\" style=\"position:absolute;right:-12px;top:-12px;\" />";
	s += "</div>";
	return s;
}
core.HtmlHelper.toInputPwdHtml = function() {
	var left = (RunTime.clientWidth - 300) / 2;
	var top = (RunTime.clientHeight - 180) / 2;
	var pos = "position:absolute; left:" + Std.string(Math.round(left)) + "px; top:" + Std.string(Math.round(top)) + "px;";
	var s = "";
	s += "<div id=\"inputBox\" style=\" " + pos + " width:300px; height:120px;background-color:#CCCCCC; \">";
	s += "<p>Please input password below:</p>";
	s += "<input id=\"tbKeyword\" type=\"password\" style=\"width:120px; height:20px; \"  onkeypress=\"return onInputKeyPress(event)\" />";
	s += "<input type=\"button\" style=\"height:20px; \" value=\"Submit\" onclick=\"inputPwd(); \" />";
	s += "</div>";
	return s;
}
core.HtmlHelper.prototype.__class__ = core.HtmlHelper;
CData = function(p) { if( p === $_ ) return; {
	null;
}}
CData.__name__ = ["CData"];
CData.prototype.key = null;
CData.prototype.val = null;
CData.prototype.__class__ = CData;
Xml2Html = function(p) { if( p === $_ ) return; {
	null;
}}
Xml2Html.__name__ = ["Xml2Html"];
Xml2Html.prototype.map = null;
Xml2Html.prototype.getCData = function(key) {
	if(this.map == null) return null;
	{
		var _g1 = 0, _g = this.map.length;
		while(_g1 < _g) {
			var i = _g1++;
			var item = this.map[i];
			if(item.key == key) {
				return item.val;
			}
		}
	}
	return null;
}
Xml2Html.prototype.prepareXmlAsHtml = function(txt) {
	this.map = new Array();
	txt = StringTools.replace(txt,"<![CDATA[","]]>");
	var lines = txt.split("]]>");
	if(lines.length == 0) return txt;
	var buff = new StringBuf();
	var k = 0;
	{
		var _g1 = 0, _g = lines.length;
		while(_g1 < _g) {
			var i = _g1++;
			var val = lines[i];
			if(i % 2 == 0) {
				buff.b[buff.b.length] = val;
			}
			else {
				var key = Std.string(k);
				buff.b[buff.b.length] = "<cdata>" + key + "</cdata>";
				var cdata = new CData();
				cdata.key = key;
				cdata.val = val;
				this.map.push(cdata);
				k++;
			}
		}
	}
	return buff.b.join("");
}
Xml2Html.prototype.__class__ = Xml2Html;
FlipBook = function(p) { if( p === $_ ) return; {
	this.bookContext = new core.BookContext();
	this.tweener = new core.Tweener();
	this.currentPageNum = 0;
}}
FlipBook.__name__ = ["FlipBook"];
FlipBook.prototype.canvas = null;
FlipBook.prototype.root = null;
FlipBook.prototype.mask = null;
FlipBook.prototype.cvsVideo = null;
FlipBook.prototype.cvsOthers = null;
FlipBook.prototype.cvsAudio = null;
FlipBook.prototype.cvsYoutube = null;
FlipBook.prototype.maskPopup = null;
FlipBook.prototype.btnPrevPage = null;
FlipBook.prototype.btnNextPage = null;
FlipBook.prototype.btnFirstPage = null;
FlipBook.prototype.btnLastPage = null;
FlipBook.prototype.btnAutoFlip = null;
FlipBook.prototype.btnZoom = null;
FlipBook.prototype.tbPageCount = null;
FlipBook.prototype.btnContents = null;
FlipBook.prototype.btnThumbs = null;
FlipBook.prototype.btnShowTxt = null;
FlipBook.prototype.btnSearch = null;
FlipBook.prototype.imgLogo = null;
FlipBook.prototype.tbPage = null;
FlipBook.prototype.topBar = null;
FlipBook.prototype.bottomBar = null;
FlipBook.prototype.bottomBarBg = null;
FlipBook.prototype.topBarContent = null;
FlipBook.prototype.menuParent = null;
FlipBook.prototype.bookContext = null;
FlipBook.prototype.tweener = null;
FlipBook.prototype.getContext = function() {
	return this.canvas.getContext("2d");
}
FlipBook.prototype.attachActions = function() {
	if(this.root == null) return;
	this.mask.onclick = $closure(this,"onMouseDown");
	this.mask.ontouchstart = $closure(this,"onTouchStart");
	this.mask.ontouchmove = $closure(this,"onTouchMove");
	this.mask.ontouchend = $closure(this,"onTouchEnd");
	this.mask.ontouchcancel = $closure(this,"onTouchEnd");
	this.mask.ongestureend = $closure(this,"onGestureEnd");
	this.mask.ongesturestart = $closure(this,"onGestureStart");
	this.mask.ongesturechange = $closure(this,"onGestureChange");
	this.mask.onscroll = $closure(this,"forbidden");
	this.mask.onmousewheel = $closure(this,"forbidden");
	this.maskPopup.onscroll = $closure(this,"forbidden");
	this.maskPopup.onmousewheel = $closure(this,"forbidden");
	this.topBarContent.ontouchstart = $closure(this,"onTopBarTouchStart");
	this.topBarContent.ontouchmove = $closure(this,"onTopBarTouchMove");
	this.topBarContent.ontouchend = $closure(this,"onTopBarTouchEnd");
	this.topBarContent.ontouchcancel = $closure(this,"onTopBarTouchEnd");
	this.btnNextPage.onmousedown = $closure(this,"turnToNextPage");
	this.btnPrevPage.onmousedown = $closure(this,"turnToPrevPage");
	this.btnFirstPage.onmousedown = $closure(this,"turnToFirstPage");
	this.btnLastPage.onmousedown = $closure(this,"turnToLastPage");
	this.btnContents.onclick = $closure(this,"onContentsClick");
	this.btnThumbs.onclick = $closure(this,"onThumbsClick");
	this.btnSearch.onclick = $closure(this,"onSearchClick");
	this.btnAutoFlip.onclick = $closure(this,"onAutoFlipClick");
	this.btnShowTxt.onclick = $closure(this,"onShowTxtClick");
	this.tbPage.onfocus = $closure(this,"onTbPageFocus");
	this.btnZoom.onclick = $closure(this,"onZoomClick");
}
FlipBook.prototype.forbidden = function(e) {
	e.stopPropagation();
}
FlipBook.prototype.afterInit = function() {
	null;
}
FlipBook.prototype.currentPageNum = null;
FlipBook.prototype.loadPage = function(index) {
	this.preloadPages(index);
	this.currentPageNum = index;
	this.loadCtxHotlinks();
	this.bookContext.addPage(RunTime.getPage(this.currentPageNum));
	this.bookContext.render();
	var p = this.currentPageNum;
	if(p == null) p = 0;
	RunTime.logPageView(p + 1);
}
FlipBook.prototype.onMouseDown = function(e) {
	e.stopPropagation();
	var hotlink = this.bookContext.getHotLinkAt(e.clientX,e.clientY);
	if(hotlink != null) {
		hotlink.click();
		return;
	}
	var button = this.bookContext.getButtonAt(e.clientX,e.clientY);
	if(button != null) {
		button.click();
		return;
	}
	if(this.bottomBarBg.style.opacity != RunTime.bottomBarAlpha) {
		this.showBottomBar(e);
	}
	else {
		this.hideBottomBar(e);
	}
}
FlipBook.prototype.turnPage = function(pageOffset) {
	if(pageOffset == 0) return;
	if(RunTime.book == null || RunTime.book.pages == null) return;
	var dstPageNum = this.currentPageNum + pageOffset;
	var dstPage = RunTime.getPage(dstPageNum);
	if(dstPage == null) return;
	this.setCurrentPage(dstPageNum + 1);
	var self = this;
	this.bookContext.removeAllPages();
	this.bookContext.addPage(RunTime.getPage(this.currentPageNum,0));
	this.bookContext.addPage(RunTime.getPage(this.currentPageNum,1));
	this.bookContext.addPage(RunTime.getPage(this.currentPageNum,-1));
	this.bookContext.pageOffset = 0;
	if(this.tweener != null) {
		this.tweener.stop();
	}
	var maxCount = 8;
	this.tweener.onChange = function(count) {
		var ratio = count / maxCount;
		self.bookContext.pageOffset = -pageOffset * ratio * ratio * ratio;
		if(count == maxCount) {
			self.bookContext.pageOffset = -pageOffset;
		}
		if(count == maxCount) {
			self.currentPageNum = dstPageNum;
			self.loadCtxHotlinks();
			self.loadCtxButtons();
			self.updateVideos();
			RunTime.logPageView(dstPageNum + 1);
		}
		self.bookContext.render();
	}
	this.clearCtxHotlinks();
	this.clearCtxButtons();
	this.clearVideos();
	this.tweener.start(Std["int"](maxCount));
}
FlipBook.prototype.turnToPage = function(pageNum) {
	this.preloadPages(pageNum);
	var page = RunTime.getPage(pageNum);
	if(page == null) return;
	this.setCurrentPage(pageNum + 1);
	this.currentPageNum = pageNum;
	this.loadCtxHotlinks();
	this.loadCtxButtons();
	this.clearVideos();
	this.bookContext.removeAllPages();
	this.bookContext.addPage(page);
	this.bookContext.pageOffset = 0;
	this.bookContext.render();
	this.updateVideos();
	RunTime.logPageView(pageNum + 1);
}
FlipBook.prototype.turnToNextPage = function(e) {
	this.stopFlip();
	this.turnPage(1);
}
FlipBook.prototype.turnToPrevPage = function(e) {
	this.stopFlip();
	this.turnPage(-1);
}
FlipBook.prototype.turnToFirstPage = function(e) {
	this.stopFlip();
	this.turnToPage(0);
}
FlipBook.prototype.turnToLastPage = function(e) {
	this.stopFlip();
	this.turnToPage(RunTime.book.pages.length - 1);
}
FlipBook.prototype.setPageCount = function(val) {
	this.tbPageCount.innerHTML = "/&nbsp;" + Std.string(val);
}
FlipBook.prototype.setCurrentPage = function(val) {
	var t = this.tbPage;
	t.value = Std.string(val);
}
FlipBook.prototype.touchActive = null;
FlipBook.prototype.touchX = null;
FlipBook.prototype.lastTouchTime = null;
FlipBook.prototype.onTouchStart = function(e) {
	var date = Date.now();
	e.stopPropagation();
	var obj = e;
	var touch = obj.touches[0];
	if(this.lastTouchTime != null) {
		var lastTime = this.lastTouchTime.getTime();
		var newTime = date.getTime();
		if(newTime - lastTime < RunTime.doubleClickIntervalMs) {
			this.lastTouchTime = null;
			this.zoomAt(touch,touch);
			return;
		}
	}
	this.lastTouchTime = date;
	this.stopFlip();
	this.touchActive = true;
	if(obj.touches.length > 1) {
		this.touchActive = false;
		var touch2 = obj.touches[1];
		this.zoomAt(touch,touch2);
	}
	this.touchX = touch.clientX;
}
FlipBook.prototype.zoomAt = function(point0,point1) {
	var num = 0;
	if(this.currentPageNum != null) num = this.currentPageNum;
	var page = RunTime.getPage(num);
	this.zoomIn(page);
}
FlipBook.prototype.zoomIn = function(page) {
	if(page == null) return;
	js.Lib.window.location.href = RunTime.urlZoom + "?img=" + page.urlFullPage + "&page=" + page.num + "&pw=" + RunTime.book.pageWidth + "&ph=" + RunTime.book.pageHeight + "&bookId=" + RunTime.book.bookId + "&bookTitle=" + RunTime.book.bookTitle + "&bbv=" + this.getCurrentBBV() + "&ua=" + RunTime.book.analyticsUA + "&pcode=" + RunTime.pcode;
}
FlipBook.prototype.getFullUrl = function() {
	return RunTime.urlIndex + "?page=" + Std.string(this.currentPageNum) + "&bbv=" + this.getCurrentBBV() + "&pcode=" + RunTime.pcode;
}
FlipBook.prototype.onTouchEnd = function(e) {
	e.stopPropagation();
	this.touchActive = false;
}
FlipBook.prototype.onTouchMove = function(e) {
	e.stopPropagation();
	if(this.touchActive == false) return;
	var obj = e;
	var touch = obj.touches[0];
	var offset = touch.clientX - this.touchX;
	if(offset > 0) {
		this.turnPage(-1);
		this.touchActive = false;
	}
	else if(offset < 0) {
		this.turnPage(1);
		this.touchActive = false;
	}
	obj.preventDefault();
}
FlipBook.prototype.onGestureStart = function(e) {
	e.stopPropagation();
}
FlipBook.prototype.onGestureChange = function(e) {
	e.stopPropagation();
}
FlipBook.prototype.onGestureEnd = function(e) {
	e.stopPropagation();
}
FlipBook.prototype.touchTopBarActive = null;
FlipBook.prototype.touchTopBarY = null;
FlipBook.prototype.onTopBarTouchStart = function(e) {
	this.touchTopBarActive = true;
	var obj = e;
	var touch = obj.touches.item(0);
	this.touchTopBarY = touch.clientY;
}
FlipBook.prototype.onTopBarTouchEnd = function(e) {
	this.touchTopBarActive = false;
}
FlipBook.prototype.onTopBarTouchMove = function(e) {
	var obj = e;
	var touch = obj.touches.item(0);
	var offset = touch.clientY - this.touchTopBarY;
	this.topBarContent.scrollTop += Std["int"](Math.round(offset));
	obj.preventDefault();
}
FlipBook.prototype.clearCtxHotlinks = function() {
	this.bookContext.hotlinks = null;
}
FlipBook.prototype.clearCtxButtons = function() {
	this.bookContext.buttons = null;
}
FlipBook.prototype.loadCtxHotlinks = function() {
	var links = new Array();
	if(RunTime.book != null && RunTime.book.hotlinks != null) {
		var current = 0;
		if(this.currentPageNum != null) current = this.currentPageNum;
		{
			var _g1 = 0, _g = RunTime.book.hotlinks.length;
			while(_g1 < _g) {
				var i = _g1++;
				var item = RunTime.book.hotlinks[i];
				if(item.pageNum == current) {
					links.push(item);
				}
			}
		}
	}
	this.bookContext.hotlinks = links;
}
FlipBook.prototype.loadCtxVideos = function() {
	var videos = new Array();
	if(RunTime.book != null && RunTime.book.videos != null) {
		var current = 0;
		if(this.currentPageNum != null) current = this.currentPageNum;
		{
			var _g1 = 0, _g = RunTime.book.videos.length;
			while(_g1 < _g) {
				var i = _g1++;
				var item = RunTime.book.videos[i];
				if(item.pageNum == current) {
					videos.push(item);
				}
			}
		}
	}
	this.bookContext.videos = videos;
}
FlipBook.prototype.hideTopBar = function() {
	this.setVisible(this.topBar,false);
	this.currentTopBarButton = null;
}
FlipBook.prototype.setVisible = function(dom,val) {
	if(val == true) {
		dom.style.display = "inline";
	}
	else {
		dom.style.display = "none";
	}
}
FlipBook.prototype.setTopTitle = function(val) {
	var dom = js.Lib.document.getElementById("topTitle");
	dom.innerHTML = val;
}
FlipBook.prototype.resetAndShowTopBar = function(type) {
	if(type == null) type = "";
	var t = new core.Tweener();
	var dom = this.topBar;
	dom.style.height = "0px";
	var self = this;
	self.setVisible(self.topBarContent,false);
	t.start(10);
	t.onChange = function(count) {
		dom.style.height = Std.string(count * 30) + "px";
		if(count == 10) {
			self.setVisible(self.topBarContent,true);
			if(type == "search") {
				self.focusSearchInput();
			}
		}
	}
	this.setVisible(this.topBar,true);
	this.topBarContent.innerHTML = "";
}
FlipBook.prototype.focusSearchInput = function() {
	var t = new core.Tweener();
	var self = this;
	t.start(10);
	t.onChange = function(count) {
		if(count == 10) {
			var input = self.getSearchInputDom();
			input.focus();
		}
	}
}
FlipBook.prototype.currentTopBarButton = null;
FlipBook.prototype.onContentsClick = function(e) {
	this.stopFlip();
	if(this.currentTopBarButton == this.btnContents) {
		this.hideTopBar();
		return;
	}
	this.resetAndShowTopBar("toc");
	this.currentTopBarButton = this.btnContents;
	this.setTopTitle("Table of Contents");
	if(RunTime.contentInfo != null) {
		var html = core.HtmlHelper.toContentsHtml(RunTime.contentInfo);
		this.topBarContent.innerHTML = html;
	}
}
FlipBook.prototype.onThumbsClick = function(e) {
	this.stopFlip();
	if(this.currentTopBarButton == this.btnThumbs) {
		this.hideTopBar();
		return;
	}
	this.resetAndShowTopBar("thumbs");
	this.setTopTitle("Thumbs");
	this.currentTopBarButton = this.btnThumbs;
	var html = core.HtmlHelper.toThumbsHtml(RunTime.book.pages);
	this.topBarContent.innerHTML = html;
}
FlipBook.prototype.onSearchClick = function(e) {
	this.stopFlip();
	if(this.currentTopBarButton == this.btnSearch) {
		this.hideTopBar();
		return;
	}
	this.resetAndShowTopBar("search");
	this.setTopTitle("Search");
	this.currentTopBarButton = this.btnSearch;
	var html = core.HtmlHelper.toSearchHtml();
	this.topBarContent.innerHTML = html;
}
FlipBook.prototype.onTbPageFocus = function(e) {
	this.stopFlip();
	var obj = this.tbPage;
	obj.value = "";
}
FlipBook.prototype.searchWord = null;
FlipBook.prototype.search = function() {
	var input = this.getSearchInputDom();
	var word = input.value;
	word = StringTools.trim(word);
	if(word == "") return;
	this.searchWord = word.toLowerCase();
	RunTime.requestSearch($closure(this,"searchCore"));
	RunTime.logSearch(this.searchWord);
}
FlipBook.prototype.inputPwd = function() {
	var dom = this.cvsOthers;
	var inputDom = dom.getElementsByTagName("input")[0];
	var word = inputDom.value;
	word = StringTools.trim(word);
	RunTime.tryPwd(word);
}
FlipBook.prototype.getSearchInputDom = function() {
	var dom = this.topBarContent;
	var inputDom = dom.getElementsByTagName("input")[0];
	return inputDom;
}
FlipBook.prototype.searchCore = function(pages) {
	if(this.searchWord == "") return;
	var list = this.searchInPages(pages);
	var dom = this.topBarContent;
	var resultsDom = dom.getElementsByTagName("div")[1];
	if(list == null || list.length == 0) {
		resultsDom.innerHTML = "0 Results.";
	}
	else {
		resultsDom.innerHTML = core.HtmlHelper.toSearchResultHtml(list);
	}
}
FlipBook.prototype.searchInPages = function(pages) {
	var results = [];
	{
		var _g1 = 0, _g = pages.length;
		while(_g1 < _g) {
			var i = _g1++;
			var item = pages[i];
			if(item.content == null || item.content == "") continue;
			if(item.contentLowerCase == null) {
				item.contentLowerCase = item.content.toLowerCase();
			}
			var posList = orc.utils.Util.searchPos(item.contentLowerCase,this.searchWord);
			results = results.concat(orc.utils.Util.createSearchResults(item.content,this.searchWord,posList,Std.parseInt(item.id)));
		}
	}
	return results;
}
FlipBook.prototype.isAutoFliping = null;
FlipBook.prototype.flipTweener = null;
FlipBook.prototype.getCurrentPageNum = function() {
	var num = 0;
	if(this.currentPageNum != null) {
		num = this.currentPageNum;
	}
	return num;
}
FlipBook.prototype.stopFlip = function(resetFlipFlag) {
	if(resetFlipFlag == null) resetFlipFlag = true;
	if(this.flipTweener != null) {
		this.flipTweener.onChange = null;
		this.flipTweener.stop();
		this.flipTweener = null;
	}
	if(resetFlipFlag == true) {
		this.isAutoFliping = false;
		this.btnAutoFlip.style.opacity = 1;
	}
}
FlipBook.prototype.preloadPages = function(num) {
	if(RunTime.enablePreload == false) return;
	RunTime.book.preloadPages(num);
}
FlipBook.prototype.canTurnRight = function() {
	var num = this.getCurrentPageNum();
	return num < RunTime.book.pages.length - 1;
}
FlipBook.prototype.onAutoFlipClick = function(e) {
	this.stopFlip(false);
	this.hideTopBar();
	if(this.isAutoFliping == true) {
		this.isAutoFliping = false;
		this.btnAutoFlip.style.opacity = 0;
	}
	else {
		this.isAutoFliping = true;
		this.btnAutoFlip.style.opacity = RunTime.autoflipButtonUnselectedAlpha;
		this.flipTweener = new core.Tweener();
		var self = this;
		var countOfClip = 50;
		this.flipTweener.onChange = function(count) {
			if(count % countOfClip != 0) return;
			if(self.isAutoFliping == false) return;
			if(self.canTurnRight() == true) {
				self.turnPage(1);
			}
			else {
				self.stopFlip();
			}
		}
		this.flipTweener.start(1000000);
	}
}
FlipBook.prototype.onZoomClick = function(e) {
	this.zoomAt(null,null);
}
FlipBook.prototype.onShowTxtClick = function(e) {
	this.stopFlip();
	if(this.currentTopBarButton == this.btnShowTxt) {
		this.hideTopBar();
		return;
	}
	RunTime.requestSearch($closure(this,"showTxtCore"));
}
FlipBook.prototype.showTxtCore = function(pages) {
	var result = "";
	{
		var _g1 = 0, _g = pages.length;
		while(_g1 < _g) {
			var i = _g1++;
			var item = pages[i];
			if(item.id == Std.string(this.getCurrentPageNum())) {
				result = item.content;
				break;
			}
		}
	}
	result = StringTools.replace(result,"\n","<br />");
	this.resetAndShowTopBar("text");
	this.setTopTitle("Text");
	this.currentTopBarButton = this.btnShowTxt;
	this.topBarContent.innerHTML = result;
}
FlipBook.prototype.hideBottomBar = function(e,animate) {
	if(animate == null) animate = true;
	if(e != null) {
		var t = e.target;
		if(t == this.btnAutoFlip || t == this.btnContents || t == this.btnFirstPage || t == this.btnLastPage || t == this.btnNextPage || t == this.btnPrevPage || t == this.btnSearch || t == this.btnThumbs || t == this.tbPage || t == this.imgLogo) {
			return;
		}
	}
	if(animate == false) {
		this.bottomBarBg.style.opacity = 0;
		this.bottomBar.style.display = "none";
		RunTime.saveBottomBarVisible(false);
	}
	var self = this;
	var alpha = RunTime.bottomBarAlpha;
	var max = 60;
	var t = new core.Tweener();
	t.onChange = function(count) {
		var alpha1 = alpha - count * alpha / max;
		self.bottomBarBg.style.opacity = alpha1;
		if(alpha1 < 0) alpha1 = 0;
		if(alpha1 < 0.05) {
			self.bottomBar.style.display = "none";
		}
	}
	t.start(max);
	RunTime.saveBottomBarVisible(false);
}
FlipBook.prototype.getCurrentBBV = function() {
	if(this.bottomBar.style.display == "inline") return "1";
	else return "0";
}
FlipBook.prototype.showBottomBar = function(e) {
	this.bottomBar.style.display = "inline";
	this.bottomBarBg.style.opacity = RunTime.bottomBarAlpha;
	RunTime.saveBottomBarVisible(true);
}
FlipBook.prototype.clearVideos = function() {
	this.cvsVideo.innerHTML = "";
}
FlipBook.prototype.updateVideos = function() {
	this.loadCtxVideos();
	var videos = this.bookContext.videos;
	if(videos != null) {
		{
			var _g1 = 0, _g = videos.length;
			while(_g1 < _g) {
				var i = _g1++;
				var item = videos[i];
				this.renderVideo(item);
			}
		}
	}
}
FlipBook.prototype.renderVideo = function(item) {
	this.cvsVideo.innerHTML += core.HtmlHelper.toVideoHtml(item);
}
FlipBook.prototype.loadCtxButtons = function() {
	var buttons = new Array();
	if(RunTime.book != null && RunTime.book.buttons != null) {
		var current = 0;
		if(this.currentPageNum != null) current = this.currentPageNum;
		{
			var _g1 = 0, _g = RunTime.book.buttons.length;
			while(_g1 < _g) {
				var i = _g1++;
				var item = RunTime.book.buttons[i];
				if(item.pageNum == current) {
					buttons.push(item);
				}
			}
		}
	}
	this.bookContext.buttons = buttons;
}
FlipBook.prototype.__class__ = FlipBook;
if(!haxe.io) haxe.io = {}
haxe.io.Bytes = function(length,b) { if( length === $_ ) return; {
	this.length = length;
	this.b = b;
}}
haxe.io.Bytes.__name__ = ["haxe","io","Bytes"];
haxe.io.Bytes.alloc = function(length) {
	var a = new Array();
	{
		var _g = 0;
		while(_g < length) {
			var i = _g++;
			a.push(0);
		}
	}
	return new haxe.io.Bytes(length,a);
}
haxe.io.Bytes.ofString = function(s) {
	var a = new Array();
	{
		var _g1 = 0, _g = s.length;
		while(_g1 < _g) {
			var i = _g1++;
			var c = s.cca(i);
			if(c <= 127) a.push(c);
			else if(c <= 2047) {
				a.push(192 | c >> 6);
				a.push(128 | c & 63);
			}
			else if(c <= 65535) {
				a.push(224 | c >> 12);
				a.push(128 | c >> 6 & 63);
				a.push(128 | c & 63);
			}
			else {
				a.push(240 | c >> 18);
				a.push(128 | c >> 12 & 63);
				a.push(128 | c >> 6 & 63);
				a.push(128 | c & 63);
			}
		}
	}
	return new haxe.io.Bytes(a.length,a);
}
haxe.io.Bytes.ofData = function(b) {
	return new haxe.io.Bytes(b.length,b);
}
haxe.io.Bytes.prototype.length = null;
haxe.io.Bytes.prototype.b = null;
haxe.io.Bytes.prototype.get = function(pos) {
	return this.b[pos];
}
haxe.io.Bytes.prototype.set = function(pos,v) {
	this.b[pos] = v & 255;
}
haxe.io.Bytes.prototype.blit = function(pos,src,srcpos,len) {
	if(pos < 0 || srcpos < 0 || len < 0 || pos + len > this.length || srcpos + len > src.length) throw haxe.io.Error.OutsideBounds;
	var b1 = this.b;
	var b2 = src.b;
	if(b1 == b2 && pos > srcpos) {
		var i = len;
		while(i > 0) {
			i--;
			b1[i + pos] = b2[i + srcpos];
		}
		return;
	}
	{
		var _g = 0;
		while(_g < len) {
			var i = _g++;
			b1[i + pos] = b2[i + srcpos];
		}
	}
}
haxe.io.Bytes.prototype.sub = function(pos,len) {
	if(pos < 0 || len < 0 || pos + len > this.length) throw haxe.io.Error.OutsideBounds;
	return new haxe.io.Bytes(len,this.b.slice(pos,pos + len));
}
haxe.io.Bytes.prototype.compare = function(other) {
	var b1 = this.b;
	var b2 = other.b;
	var len = this.length < other.length?this.length:other.length;
	{
		var _g = 0;
		while(_g < len) {
			var i = _g++;
			if(b1[i] != b2[i]) return b1[i] - b2[i];
		}
	}
	return this.length - other.length;
}
haxe.io.Bytes.prototype.readString = function(pos,len) {
	if(pos < 0 || len < 0 || pos + len > this.length) throw haxe.io.Error.OutsideBounds;
	var s = "";
	var b = this.b;
	var fcc = $closure(String,"fromCharCode");
	var i = pos;
	var max = pos + len;
	while(i < max) {
		var c = b[i++];
		if(c < 128) {
			if(c == 0) break;
			s += fcc(c);
		}
		else if(c < 224) s += fcc((c & 63) << 6 | b[i++] & 127);
		else if(c < 240) {
			var c2 = b[i++];
			s += fcc((c & 31) << 12 | (c2 & 127) << 6 | b[i++] & 127);
		}
		else {
			var c2 = b[i++];
			var c3 = b[i++];
			s += fcc((c & 15) << 18 | (c2 & 127) << 12 | c3 << 6 & 127 | b[i++] & 127);
		}
	}
	return s;
}
haxe.io.Bytes.prototype.toString = function() {
	return this.readString(0,this.length);
}
haxe.io.Bytes.prototype.getData = function() {
	return this.b;
}
haxe.io.Bytes.prototype.__class__ = haxe.io.Bytes;
IntIter = function(min,max) { if( min === $_ ) return; {
	this.min = min;
	this.max = max;
}}
IntIter.__name__ = ["IntIter"];
IntIter.prototype.min = null;
IntIter.prototype.max = null;
IntIter.prototype.hasNext = function() {
	return this.min < this.max;
}
IntIter.prototype.next = function() {
	return this.min++;
}
IntIter.prototype.__class__ = IntIter;
haxe.Timer = function(time_ms) { if( time_ms === $_ ) return; {
	this.id = haxe.Timer.arr.length;
	haxe.Timer.arr[this.id] = this;
	this.timerId = window.setInterval("haxe.Timer.arr[" + this.id + "].run();",time_ms);
}}
haxe.Timer.__name__ = ["haxe","Timer"];
haxe.Timer.delay = function(f,time_ms) {
	var t = new haxe.Timer(time_ms);
	t.run = function() {
		t.stop();
		f();
	}
	return t;
}
haxe.Timer.measure = function(f,pos) {
	var t0 = haxe.Timer.stamp();
	var r = f();
	haxe.Log.trace(haxe.Timer.stamp() - t0 + "s",pos);
	return r;
}
haxe.Timer.stamp = function() {
	return Date.now().getTime() / 1000;
}
haxe.Timer.prototype.id = null;
haxe.Timer.prototype.timerId = null;
haxe.Timer.prototype.stop = function() {
	if(this.id == null) return;
	window.clearInterval(this.timerId);
	haxe.Timer.arr[this.id] = null;
	if(this.id > 100 && this.id == haxe.Timer.arr.length - 1) {
		var p = this.id - 1;
		while(p >= 0 && haxe.Timer.arr[p] == null) p--;
		haxe.Timer.arr = haxe.Timer.arr.slice(0,p + 1);
	}
	this.id = null;
}
haxe.Timer.prototype.run = function() {
	null;
}
haxe.Timer.prototype.__class__ = haxe.Timer;
haxe.io.Error = { __ename__ : ["haxe","io","Error"], __constructs__ : ["Blocked","Overflow","OutsideBounds","Custom"] }
haxe.io.Error.Blocked = ["Blocked",0];
haxe.io.Error.Blocked.toString = $estr;
haxe.io.Error.Blocked.__enum__ = haxe.io.Error;
haxe.io.Error.Overflow = ["Overflow",1];
haxe.io.Error.Overflow.toString = $estr;
haxe.io.Error.Overflow.__enum__ = haxe.io.Error;
haxe.io.Error.OutsideBounds = ["OutsideBounds",2];
haxe.io.Error.OutsideBounds.toString = $estr;
haxe.io.Error.OutsideBounds.__enum__ = haxe.io.Error;
haxe.io.Error.Custom = function(e) { var $x = ["Custom",3,e]; $x.__enum__ = haxe.io.Error; $x.toString = $estr; return $x; }
Std = function() { }
Std.__name__ = ["Std"];
Std["is"] = function(v,t) {
	return js.Boot.__instanceof(v,t);
}
Std.string = function(s) {
	return js.Boot.__string_rec(s,"");
}
Std["int"] = function(x) {
	if(x < 0) return Math.ceil(x);
	return Math.floor(x);
}
Std.parseInt = function(x) {
	var v = parseInt(x,10);
	if(v == 0 && x.charCodeAt(1) == 120) v = parseInt(x);
	if(isNaN(v)) return null;
	return v;
}
Std.parseFloat = function(x) {
	return parseFloat(x);
}
Std.random = function(x) {
	return Math.floor(Math.random() * x);
}
Std.prototype.__class__ = Std;
DoubleFlipBook = function(p) { if( p === $_ ) return; {
	FlipBook.call(this);
}}
DoubleFlipBook.__name__ = ["DoubleFlipBook"];
DoubleFlipBook.__super__ = FlipBook;
for(var k in FlipBook.prototype ) DoubleFlipBook.prototype[k] = FlipBook.prototype[k];
DoubleFlipBook.prototype.afterInit = function() {
	this.tbPage.style.width = "60px";
}
DoubleFlipBook.prototype.loadPage = function(index) {
	this.preloadPages(index);
	this.currentPageNum = index;
	this.loadCtxHotlinks();
	this.loadCtxButtons();
	this.updateVideos();
	var p = this.getCurrentPair();
	this.bookContext.addPage(p.leftPage);
	this.bookContext.addPage(p.rightPage);
	this.bookContext.render();
	if(p.leftPage != null) {
		RunTime.logPageView(p.leftPage.num + 1);
	}
	if(p.rightPage != null) {
		RunTime.logPageView(p.rightPage.num + 1);
	}
}
DoubleFlipBook.prototype.turnToPage = function(pageNum) {
	this.preloadPages(pageNum);
	var current = this.getCurrentPageNum();
	if(current < 0 || current >= RunTime.book.pages.length) return;
	if(pageNum < 0 || pageNum >= RunTime.book.pages.length) return;
	this.bookContext.removeAllPages();
	var oldPair = new core.PagePair(current);
	var newPair = new core.PagePair(pageNum);
	var oldNum = oldPair.getNumInDoubleMode();
	var newNum = newPair.getNumInDoubleMode();
	if(newNum < 0 || oldNum == newNum) return;
	this.setCurrentPage(pageNum + 1);
	this.bookContext.addPage(oldPair.leftPage);
	this.bookContext.addPage(oldPair.rightPage);
	this.bookContext.addPage(newPair.leftPage);
	this.bookContext.addPage(newPair.rightPage);
	if(newPair.leftPage != null) {
		RunTime.logPageView(newPair.leftPage.num + 1);
	}
	if(newPair.rightPage != null) {
		RunTime.logPageView(newPair.rightPage.num + 1);
	}
	this.bookContext.pageOffset = 0;
	var pageOffset = 0;
	var offset = 0;
	var dstPageOffset = newNum > oldNum?1:-1;
	var ldp = RunTime.getDrawParams(-1);
	var rdp = RunTime.getDrawParams(1);
	var update = function(val) {
		var downLeft = oldPair.leftPage;
		var downRight = oldPair.rightPage;
		var upLeft = newPair.leftPage;
		var upRight = newPair.rightPage;
		if(dstPageOffset > 0) {
			if(downLeft != null) {
				if(val <= 0.5) {
					downLeft.drawParams = ldp;
				}
				else {
					downLeft.drawParams = ldp.sliceLeft(2 - val * 2);
				}
			}
			if(downRight != null) {
				if(val <= 0.5) {
					downRight.drawParams = rdp.sliceLeft(1 - 2 * val);
				}
				else {
					downRight.drawParams = null;
				}
			}
			if(upLeft != null) {
				upLeft.drawParams = ldp.sliceLeft(val,ldp.dw * 2 * (1 - val));
			}
			if(upRight != null) {
				upRight.drawParams = rdp.sliceRight(val);
			}
		}
		else {
			val = -val;
			if(downLeft != null) {
				if(val <= 0.5) {
					downLeft.drawParams = ldp.sliceRight(1 - 2 * val);
				}
				else {
					downLeft.drawParams = null;
				}
			}
			if(downRight != null) {
				if(val <= 0.5) {
					downRight.drawParams = rdp;
				}
				else {
					downRight.drawParams = rdp.sliceRight(2 - val * 2);
				}
			}
			if(upLeft != null) {
				upLeft.drawParams = ldp.sliceLeft(val);
			}
			if(upRight != null) {
				upRight.drawParams = rdp.sliceRight(val,-rdp.dw * 2 * (1 - val));
			}
		}
	}
	update(0);
	if(this.tweener != null) {
		this.tweener.stop();
	}
	var self = this;
	var ctx = this.bookContext;
	var maxCount = 8;
	this.tweener.onChange = function(count) {
		var ratio = count / maxCount;
		offset = dstPageOffset * ratio * ratio * ratio;
		update(offset);
		if(count == maxCount) {
			ctx.clear(true);
			ctx.addPage(newPair.leftPage);
			ctx.addPage(newPair.rightPage);
			self.currentPageNum = pageNum;
			self.loadCtxHotlinks();
			self.loadCtxButtons();
			self.updateVideos();
		}
		self.bookContext.render();
	}
	this.clearCtxHotlinks();
	this.clearCtxButtons();
	this.clearVideos();
	this.tweener.start(Std["int"](maxCount));
}
DoubleFlipBook.prototype.getCurrentPair = function() {
	var current = 0;
	if(this.currentPageNum != null) current = this.currentPageNum;
	return new core.PagePair(current);
}
DoubleFlipBook.prototype.loadCtxHotlinks = function() {
	var links = new Array();
	if(RunTime.book != null && RunTime.book.hotlinks != null) {
		var pair = this.getCurrentPair();
		{
			var _g1 = 0, _g = RunTime.book.hotlinks.length;
			while(_g1 < _g) {
				var i = _g1++;
				var item = RunTime.book.hotlinks[i];
				var match = pair.match(item.pageNum);
				if(match != 0) {
					item.pageLayoutType = match;
					links.push(item);
				}
			}
		}
	}
	this.bookContext.hotlinks = links;
}
DoubleFlipBook.prototype.loadCtxVideos = function() {
	var videos = new Array();
	if(RunTime.book != null && RunTime.book.videos != null) {
		var pair = this.getCurrentPair();
		{
			var _g1 = 0, _g = RunTime.book.videos.length;
			while(_g1 < _g) {
				var i = _g1++;
				var item = RunTime.book.videos[i];
				var match = pair.match(item.pageNum);
				if(match != 0) {
					item.pageLayoutType = match;
					videos.push(item);
				}
			}
		}
	}
	this.bookContext.videos = videos;
}
DoubleFlipBook.prototype.setCurrentPage = function(val) {
	var count = RunTime.book.pages.length;
	var t = this.tbPage;
	if(val == 1) {
		t.value = Std.string(val);
	}
	else if(val % 2 == 0 && val == count) {
		t.value = Std.string(val);
	}
	else {
		var v0 = val - val % 2;
		var v1 = v0 + 1;
		t.value = Std.string(v0) + "-" + Std.string(v1);
	}
}
DoubleFlipBook.prototype.turnPage = function(pageOffset) {
	var current = 0;
	if(this.currentPageNum != null) current = this.currentPageNum;
	current = current + pageOffset * 2;
	if(current < 0) current = 0;
	if(current >= RunTime.book.pages.length) {
		current = RunTime.book.pages.length - 1;
	}
	this.turnToPage(current);
}
DoubleFlipBook.prototype.zoomAt = function(point0,point1) {
	var x0 = point0.clientX;
	var x1 = point1.clientX;
	var x = 0.5 * (x0 + x1);
	var p = this.getCurrentPair();
	var page = null;
	if(p.leftPage != null) {
		if(x < p.leftPage.drawParams.dx + p.leftPage.drawParams.dw) {
			page = p.leftPage;
		}
	}
	if(p.rightPage != null) {
		if(x >= p.rightPage.drawParams.dx) {
			page = p.rightPage;
		}
	}
	this.zoomIn(page);
}
DoubleFlipBook.prototype.canTurnRight = function() {
	var num = this.getCurrentPageNum();
	var count = RunTime.book.pages.length;
	if(num % 2 == 1) num++;
	return num < count - 1;
}
DoubleFlipBook.prototype.loadCtxButtons = function() {
	var buttons = new Array();
	if(RunTime.book != null && RunTime.book.buttons != null) {
		var pair = this.getCurrentPair();
		{
			var _g1 = 0, _g = RunTime.book.buttons.length;
			while(_g1 < _g) {
				var i = _g1++;
				var item = RunTime.book.buttons[i];
				var match = pair.match(item.pageNum);
				if(match != 0) {
					item.pageLayoutType = match;
					buttons.push(item);
				}
			}
		}
	}
	this.bookContext.buttons = buttons;
}
DoubleFlipBook.prototype.__class__ = DoubleFlipBook;
orc.utils.DrawHelper = function() { }
orc.utils.DrawHelper.__name__ = ["orc","utils","DrawHelper"];
orc.utils.DrawHelper.createFillStyle = function(cssStyleColor,alpha) {
	cssStyleColor = StringTools.replace(cssStyleColor,"0x","");
	cssStyleColor = StringTools.replace(cssStyleColor,"0X","");
	cssStyleColor = StringTools.replace(cssStyleColor,"#","");
	if(cssStyleColor.length == 6) {
		var r = Std.string(Std.parseInt("0x" + cssStyleColor.substr(0,2)));
		var g = Std.string(Std.parseInt("0x" + cssStyleColor.substr(2,2)));
		var b = Std.string(Std.parseInt("0x" + cssStyleColor.substr(4,2)));
		return "rgba(" + r + "," + g + "," + b + "," + Std.string(alpha) + ")";
	}
	return "";
}
orc.utils.DrawHelper.prototype.__class__ = orc.utils.DrawHelper;
List = function(p) { if( p === $_ ) return; {
	this.length = 0;
}}
List.__name__ = ["List"];
List.prototype.h = null;
List.prototype.q = null;
List.prototype.length = null;
List.prototype.add = function(item) {
	var x = [item];
	if(this.h == null) this.h = x;
	else this.q[1] = x;
	this.q = x;
	this.length++;
}
List.prototype.push = function(item) {
	var x = [item,this.h];
	this.h = x;
	if(this.q == null) this.q = x;
	this.length++;
}
List.prototype.first = function() {
	return this.h == null?null:this.h[0];
}
List.prototype.last = function() {
	return this.q == null?null:this.q[0];
}
List.prototype.pop = function() {
	if(this.h == null) return null;
	var x = this.h[0];
	this.h = this.h[1];
	if(this.h == null) this.q = null;
	this.length--;
	return x;
}
List.prototype.isEmpty = function() {
	return this.h == null;
}
List.prototype.clear = function() {
	this.h = null;
	this.q = null;
	this.length = 0;
}
List.prototype.remove = function(v) {
	var prev = null;
	var l = this.h;
	while(l != null) {
		if(l[0] == v) {
			if(prev == null) this.h = l[1];
			else prev[1] = l[1];
			if(this.q == l) this.q = prev;
			this.length--;
			return true;
		}
		prev = l;
		l = l[1];
	}
	return false;
}
List.prototype.iterator = function() {
	return { h : this.h, hasNext : function() {
		return this.h != null;
	}, next : function() {
		if(this.h == null) return null;
		var x = this.h[0];
		this.h = this.h[1];
		return x;
	}};
}
List.prototype.toString = function() {
	var s = new StringBuf();
	var first = true;
	var l = this.h;
	s.b[s.b.length] = "{";
	while(l != null) {
		if(first) first = false;
		else s.b[s.b.length] = ", ";
		s.b[s.b.length] = Std.string(l[0]);
		l = l[1];
	}
	s.b[s.b.length] = "}";
	return s.b.join("");
}
List.prototype.join = function(sep) {
	var s = new StringBuf();
	var first = true;
	var l = this.h;
	while(l != null) {
		if(first) first = false;
		else s.b[s.b.length] = sep;
		s.b[s.b.length] = l[0];
		l = l[1];
	}
	return s.b.join("");
}
List.prototype.filter = function(f) {
	var l2 = new List();
	var l = this.h;
	while(l != null) {
		var v = l[0];
		l = l[1];
		if(f(v)) l2.add(v);
	}
	return l2;
}
List.prototype.map = function(f) {
	var b = new List();
	var l = this.h;
	while(l != null) {
		var v = l[0];
		l = l[1];
		b.add(f(v));
	}
	return b;
}
List.prototype.__class__ = List;
haxe.Http = function(url) { if( url === $_ ) return; {
	this.url = url;
	this.headers = new Hash();
	this.params = new Hash();
	this.async = true;
}}
haxe.Http.__name__ = ["haxe","Http"];
haxe.Http.requestUrl = function(url) {
	var h = new haxe.Http(url);
	h.async = false;
	var r = null;
	h.onData = function(d) {
		r = d;
	}
	h.onError = function(e) {
		throw e;
	}
	h.request(false);
	return r;
}
haxe.Http.prototype.url = null;
haxe.Http.prototype.async = null;
haxe.Http.prototype.postData = null;
haxe.Http.prototype.headers = null;
haxe.Http.prototype.params = null;
haxe.Http.prototype.setHeader = function(header,value) {
	this.headers.set(header,value);
}
haxe.Http.prototype.setParameter = function(param,value) {
	this.params.set(param,value);
}
haxe.Http.prototype.setPostData = function(data) {
	this.postData = data;
}
haxe.Http.prototype.request = function(post) {
	var me = this;
	var r = new js.XMLHttpRequest();
	var onreadystatechange = function() {
		if(r.readyState != 4) return;
		var s = (function($this) {
			var $r;
			try {
				$r = r.status;
			}
			catch( $e0 ) {
				{
					var e = $e0;
					$r = null;
				}
			}
			return $r;
		}(this));
		if(s == undefined) s = null;
		if(s != null) me.onStatus(s);
		if(s != null && s >= 200 && s < 400) me.onData(r.responseText);
		else switch(s) {
		case null: case undefined:{
			me.onError("Failed to connect or resolve host");
		}break;
		case 12029:{
			me.onError("Failed to connect to host");
		}break;
		case 12007:{
			me.onError("Unknown host");
		}break;
		default:{
			me.onError("Http Error #" + r.status);
		}break;
		}
	}
	if(this.async) r.onreadystatechange = onreadystatechange;
	var uri = this.postData;
	if(uri != null) post = true;
	else { var $it1 = this.params.keys();
	while( $it1.hasNext() ) { var p = $it1.next();
	{
		if(uri == null) uri = "";
		else uri += "&";
		uri += StringTools.urlDecode(p) + "=" + StringTools.urlEncode(this.params.get(p));
	}
	}}
	try {
		if(post) r.open("POST",this.url,this.async);
		else if(uri != null) {
			var question = this.url.split("?").length <= 1;
			r.open("GET",this.url + (question?"?":"&") + uri,this.async);
			uri = null;
		}
		else r.open("GET",this.url,this.async);
	}
	catch( $e2 ) {
		{
			var e = $e2;
			{
				this.onError(e.toString());
				return;
			}
		}
	}
	if(this.headers.get("Content-Type") == null && post && this.postData == null) r.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	{ var $it3 = this.headers.keys();
	while( $it3.hasNext() ) { var h = $it3.next();
	r.setRequestHeader(h,this.headers.get(h));
	}}
	r.send(uri);
	if(!this.async) onreadystatechange();
}
haxe.Http.prototype.onData = function(data) {
	null;
}
haxe.Http.prototype.onError = function(msg) {
	null;
}
haxe.Http.prototype.onStatus = function(status) {
	null;
}
haxe.Http.prototype.__class__ = haxe.Http;
if(typeof js=='undefined') js = {}
js.Lib = function() { }
js.Lib.__name__ = ["js","Lib"];
js.Lib.isIE = null;
js.Lib.isOpera = null;
js.Lib.document = null;
js.Lib.window = null;
js.Lib.alert = function(v) {
	alert(js.Boot.__string_rec(v,""));
}
js.Lib.eval = function(code) {
	return eval(code);
}
js.Lib.setErrorHandler = function(f) {
	js.Lib.onerror = f;
}
js.Lib.prototype.__class__ = js.Lib;
js.Boot = function() { }
js.Boot.__name__ = ["js","Boot"];
js.Boot.__unhtml = function(s) {
	return s.split("&").join("&amp;").split("<").join("&lt;").split(">").join("&gt;");
}
js.Boot.__trace = function(v,i) {
	var msg = i != null?i.fileName + ":" + i.lineNumber + ": ":"";
	msg += js.Boot.__unhtml(js.Boot.__string_rec(v,"")) + "<br/>";
	var d = document.getElementById("haxe:trace");
	if(d == null) alert("No haxe:trace element defined\n" + msg);
	else d.innerHTML += msg;
}
js.Boot.__clear_trace = function() {
	var d = document.getElementById("haxe:trace");
	if(d != null) d.innerHTML = "";
	else null;
}
js.Boot.__closure = function(o,f) {
	var m = o[f];
	if(m == null) return null;
	var f1 = function() {
		return m.apply(o,arguments);
	}
	f1.scope = o;
	f1.method = m;
	return f1;
}
js.Boot.__string_rec = function(o,s) {
	if(o == null) return "null";
	if(s.length >= 5) return "<...>";
	var t = typeof(o);
	if(t == "function" && (o.__name__ != null || o.__ename__ != null)) t = "object";
	switch(t) {
	case "object":{
		if(o instanceof Array) {
			if(o.__enum__ != null) {
				if(o.length == 2) return o[0];
				var str = o[0] + "(";
				s += "\t";
				{
					var _g1 = 2, _g = o.length;
					while(_g1 < _g) {
						var i = _g1++;
						if(i != 2) str += "," + js.Boot.__string_rec(o[i],s);
						else str += js.Boot.__string_rec(o[i],s);
					}
				}
				return str + ")";
			}
			var l = o.length;
			var i;
			var str = "[";
			s += "\t";
			{
				var _g = 0;
				while(_g < l) {
					var i1 = _g++;
					str += (i1 > 0?",":"") + js.Boot.__string_rec(o[i1],s);
				}
			}
			str += "]";
			return str;
		}
		var tostr;
		try {
			tostr = o.toString;
		}
		catch( $e0 ) {
			{
				var e = $e0;
				{
					return "???";
				}
			}
		}
		if(tostr != null && tostr != Object.toString) {
			var s2 = o.toString();
			if(s2 != "[object Object]") return s2;
		}
		var k = null;
		var str = "{\n";
		s += "\t";
		var hasp = o.hasOwnProperty != null;
		for( var k in o ) { ;
		if(hasp && !o.hasOwnProperty(k)) continue;
		if(k == "prototype" || k == "__class__" || k == "__super__" || k == "__interfaces__") continue;
		if(str.length != 2) str += ", \n";
		str += s + k + " : " + js.Boot.__string_rec(o[k],s);
		}
		s = s.substring(1);
		str += "\n" + s + "}";
		return str;
	}break;
	case "function":{
		return "<function>";
	}break;
	case "string":{
		return o;
	}break;
	default:{
		return String(o);
	}break;
	}
}
js.Boot.__interfLoop = function(cc,cl) {
	if(cc == null) return false;
	if(cc == cl) return true;
	var intf = cc.__interfaces__;
	if(intf != null) {
		var _g1 = 0, _g = intf.length;
		while(_g1 < _g) {
			var i = _g1++;
			var i1 = intf[i];
			if(i1 == cl || js.Boot.__interfLoop(i1,cl)) return true;
		}
	}
	return js.Boot.__interfLoop(cc.__super__,cl);
}
js.Boot.__instanceof = function(o,cl) {
	try {
		if(o instanceof cl) {
			if(cl == Array) return o.__enum__ == null;
			return true;
		}
		if(js.Boot.__interfLoop(o.__class__,cl)) return true;
	}
	catch( $e0 ) {
		{
			var e = $e0;
			{
				if(cl == null) return false;
			}
		}
	}
	switch(cl) {
	case Int:{
		return Math.ceil(o%2147483648.0) === o;
	}break;
	case Float:{
		return typeof(o) == "number";
	}break;
	case Bool:{
		return o === true || o === false;
	}break;
	case String:{
		return typeof(o) == "string";
	}break;
	case Dynamic:{
		return true;
	}break;
	default:{
		if(o == null) return false;
		return o.__enum__ == cl || cl == Class && o.__name__ != null || cl == Enum && o.__ename__ != null;
	}break;
	}
}
js.Boot.__init = function() {
	js.Lib.isIE = typeof document!='undefined' && document.all != null && typeof window!='undefined' && window.opera == null;
	js.Lib.isOpera = typeof window!='undefined' && window.opera != null;
	Array.prototype.copy = Array.prototype.slice;
	Array.prototype.insert = function(i,x) {
		this.splice(i,0,x);
	}
	Array.prototype.remove = Array.prototype.indexOf?function(obj) {
		var idx = this.indexOf(obj);
		if(idx == -1) return false;
		this.splice(idx,1);
		return true;
	}:function(obj) {
		var i = 0;
		var l = this.length;
		while(i < l) {
			if(this[i] == obj) {
				this.splice(i,1);
				return true;
			}
			i++;
		}
		return false;
	}
	Array.prototype.iterator = function() {
		return { cur : 0, arr : this, hasNext : function() {
			return this.cur < this.arr.length;
		}, next : function() {
			return this.arr[this.cur++];
		}};
	}
	if(String.prototype.cca == null) String.prototype.cca = String.prototype.charCodeAt;
	String.prototype.charCodeAt = function(i) {
		var x = this.cca(i);
		if(x != x) return null;
		return x;
	}
	var oldsub = String.prototype.substr;
	String.prototype.substr = function(pos,len) {
		if(pos != null && pos != 0 && len != null && len < 0) return "";
		if(len == null) len = this.length;
		if(pos < 0) {
			pos = this.length + pos;
			if(pos < 0) pos = 0;
		}
		else if(len < 0) {
			len = this.length + len - pos;
		}
		return oldsub.apply(this,[pos,len]);
	}
	$closure = js.Boot.__closure;
}
js.Boot.prototype.__class__ = js.Boot;
core.Html5Image = function(url,onLoad) { if( url === $_ ) return; {
	this.url = url;
	this.onload = onLoad;
	this.image = new Image();
	this.image.onload = this.onload;
	this.image.src = url;
}}
core.Html5Image.__name__ = ["core","Html5Image"];
core.Html5Image.prototype.image = null;
core.Html5Image.prototype.onload = null;
core.Html5Image.prototype.url = null;
core.Html5Image.prototype.__class__ = core.Html5Image;
core.BookContext = function(p) { if( p === $_ ) return; {
	this.pages = new Array();
	this.pageOffset = 0;
}}
core.BookContext.__name__ = ["core","BookContext"];
core.BookContext.prototype.ctx = null;
core.BookContext.prototype.pages = null;
core.BookContext.prototype.pageOffset = null;
core.BookContext.prototype.hotlinks = null;
core.BookContext.prototype.videos = null;
core.BookContext.prototype.buttons = null;
core.BookContext.prototype.getPageCount = function() {
	return this.pages.length;
}
core.BookContext.prototype.removeAllPages = function() {
	if(this.pages != null) {
		{
			var _g1 = 0, _g = this.pages.length;
			while(_g1 < _g) {
				var i = _g1++;
				var item = this.pages[i];
				item.visible = false;
			}
		}
	}
	this.pages = new Array();
}
core.BookContext.prototype.clear = function(removePages) {
	if(removePages == null) removePages = false;
	if(this.pages != null) {
		{
			var _g1 = 0, _g = this.pages.length;
			while(_g1 < _g) {
				var i = _g1++;
				var item = this.pages[i];
				item.visible = false;
			}
		}
	}
	if(removePages == true) {
		this.pages = new Array();
	}
	if(this.ctx != null) {
		this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height);
	}
}
core.BookContext.prototype.addPage = function(page) {
	if(page == null) return;
	if(this.pages == null) this.pages = new Array();
	page.bookContext = this;
	this.pages.push(page);
}
core.BookContext.prototype.render = function() {
	this.clear();
	if(this.pages != null && this.ctx != null) {
		{
			var _g1 = 0, _g = this.pages.length;
			while(_g1 < _g) {
				var i = _g1++;
				var item = this.pages[i];
				item.visible = true;
				item.loadToContext2D(this.ctx);
			}
		}
	}
	if(this.hotlinks != null && this.ctx != null) {
		{
			var _g1 = 0, _g = this.hotlinks.length;
			while(_g1 < _g) {
				var i = _g1++;
				var item = this.hotlinks[i];
				item.loadToContext2D(this.ctx);
			}
		}
	}
	if(this.buttons != null && this.ctx != null) {
		{
			var _g1 = 0, _g = this.buttons.length;
			while(_g1 < _g) {
				var i = _g1++;
				var item = this.buttons[i];
				item.loadToContext2D(this.ctx);
			}
		}
	}
}
core.BookContext.prototype.getHotLinkAt = function(x,y) {
	if(this.hotlinks == null) return null;
	{
		var _g1 = 0, _g = this.hotlinks.length;
		while(_g1 < _g) {
			var i = _g1++;
			var item = this.hotlinks[i];
			if(item.hitTest(x,y) == true) {
				return item;
			}
		}
	}
	return null;
}
core.BookContext.prototype.getButtonAt = function(x,y) {
	if(this.buttons == null) return null;
	{
		var _g1 = 0, _g = this.buttons.length;
		while(_g1 < _g) {
			var i = _g1++;
			var item = this.buttons[i];
			if(item.hitTest(x,y) == true) {
				return item;
			}
		}
	}
	return null;
}
core.BookContext.prototype.__class__ = core.BookContext;
core.Book = function(p) { if( p === $_ ) return; {
	this.pages = new Array();
	this.hotlinks = new Array();
	this.videos = new Array();
	this.buttons = new Array();
	this.bookId = "";
	this.bookTitle = "";
	this.analyticsUA = "";
	this.menuTocVisible = true;
	this.menuThumbsVisible = true;
	this.menuSearchVisible = true;
	this.menuAutoFlipVisible = true;
	this.menuZoomVisible = true;
}}
core.Book.__name__ = ["core","Book"];
core.Book.prototype.pages = null;
core.Book.prototype.hotlinks = null;
core.Book.prototype.videos = null;
core.Book.prototype.buttons = null;
core.Book.prototype.pageWidth = null;
core.Book.prototype.pageHeight = null;
core.Book.prototype.logoUrl = null;
core.Book.prototype.logoHref = null;
core.Book.prototype.bookId = null;
core.Book.prototype.bookTitle = null;
core.Book.prototype.bgColor = null;
core.Book.prototype.bgImageUrl = null;
core.Book.prototype.analyticsUA = null;
core.Book.prototype.password = null;
core.Book.prototype.menuTocVisible = null;
core.Book.prototype.menuThumbsVisible = null;
core.Book.prototype.menuSearchVisible = null;
core.Book.prototype.menuAutoFlipVisible = null;
core.Book.prototype.menuTxtVisible = null;
core.Book.prototype.menuZoomVisible = null;
core.Book.prototype.preloadPages = function(num) {
	if(num == null) num = 0;
	if(num < 0 || num > this.pages.length - 1) return;
	var p = [];
	p.push(num);
	p.push(num + 1);
	p.push(num - 1);
	p.push(num + 2);
	p.push(num - 2);
	p.push(num + 3);
	p.push(num - 3);
	p.push(num + 4);
	p.push(num + 5);
	{
		var _g1 = 0, _g = p.length;
		while(_g1 < _g) {
			var i = _g1++;
			var index = p[i];
			if(index >= 0 && index < this.pages.length) {
				var page = this.pages[index];
				page.getImagePage();
			}
		}
	}
}
core.Book.prototype.__class__ = core.Book;
RunTime = function() { }
RunTime.__name__ = ["RunTime"];
RunTime.bookInfo = null;
RunTime.pageInfo = null;
RunTime.hotlinkInfo = null;
RunTime.contentInfo = null;
RunTime.searchInfo = null;
RunTime.videoInfo = null;
RunTime.buttonInfo = null;
RunTime.bgImageData = null;
RunTime.flipBook = null;
RunTime.clientWidth = null;
RunTime.clientHeight = null;
RunTime.enablePreload = null;
RunTime.pageScale = null;
RunTime.imagePageWidth = null;
RunTime.imagePageHeight = null;
RunTime.defaultPageNum = null;
RunTime.alert = function(msg) {
	js.Lib.alert(msg);
}
RunTime.init = function() {
	RunTime.clientWidth = js.Lib.window.document.body.clientWidth;
	RunTime.clientHeight = js.Lib.window.document.body.clientHeight;
	RunTime.defaultPageNum = Std.parseInt(orc.utils.Util.getUrlParam("page"));
	var dom = js.Lib.document.getElementById("hiddenSearch");
	var html = dom.innerHTML;
	dom.innerHTML = "";
	RunTime.searchHtmlCache = html;
	dom = js.Lib.document.getElementById("hiddenInput");
	html = dom.innerHTML;
	dom.innerHTML = "";
	RunTime.inputHtmlCache = html;
	if(RunTime.clientHeight > RunTime.clientWidth) {
		RunTime.flipBook = new FlipBook();
	}
	else {
		RunTime.flipBook = new DoubleFlipBook();
	}
	RunTime.flipBook.root = js.Lib.document.getElementById("cvsBook");
	RunTime.flipBook.mask = js.Lib.document.getElementById("mask");
	RunTime.flipBook.tbPageCount = js.Lib.document.getElementById("tbPageCount");
	RunTime.flipBook.tbPage = js.Lib.document.getElementById("tbPage");
	RunTime.flipBook.btnContents = js.Lib.document.getElementById("btnContents");
	RunTime.flipBook.btnThumbs = js.Lib.document.getElementById("btnThumbs");
	RunTime.flipBook.btnSearch = js.Lib.document.getElementById("btnSearch");
	RunTime.flipBook.btnPrevPage = js.Lib.document.getElementById("btnPrevPage");
	RunTime.flipBook.btnNextPage = js.Lib.document.getElementById("btnNextPage");
	RunTime.flipBook.btnFirstPage = js.Lib.document.getElementById("btnFirstPage");
	RunTime.flipBook.btnLastPage = js.Lib.document.getElementById("btnLastPage");
	RunTime.flipBook.btnAutoFlip = js.Lib.document.getElementById("btnAutoFlip");
	RunTime.flipBook.btnShowTxt = js.Lib.document.getElementById("btnShowTxt");
	RunTime.flipBook.imgLogo = js.Lib.document.getElementById("imgLogo");
	RunTime.flipBook.topBar = js.Lib.document.getElementById("topBar");
	RunTime.flipBook.topBarContent = js.Lib.document.getElementById("topBarContent");
	RunTime.flipBook.bottomBar = js.Lib.document.getElementById("bottomBar");
	RunTime.flipBook.bottomBarBg = js.Lib.document.getElementById("bottomBarBg");
	RunTime.flipBook.bottomBarBg.style.opacity = RunTime.bottomBarAlpha;
	RunTime.flipBook.menuParent = js.Lib.document.getElementById("menuParent");
	RunTime.flipBook.maskPopup = js.Lib.document.getElementById("maskPopup");
	RunTime.flipBook.cvsVideo = js.Lib.document.getElementById("cvsVideo");
	RunTime.flipBook.cvsOthers = js.Lib.document.getElementById("cvsOthers");
	RunTime.flipBook.cvsAudio = js.Lib.document.getElementById("cvsAudio");
	RunTime.flipBook.cvsYoutube = js.Lib.document.getElementById("cvsYoutube");
	RunTime.flipBook.btnZoom = js.Lib.document.getElementById("btnZoom");
	var left = Std["int"]((RunTime.clientWidth - 500) / 2);
	RunTime.flipBook.topBar.style.left = Std.string(left) + "px";
	var c = RunTime.flipBook.root;
	RunTime.flipBook.canvas = c;
	RunTime.flipBook.attachActions();
	c.width = RunTime.clientWidth;
	c.height = RunTime.clientHeight;
	RunTime.flipBook.afterInit();
	RunTime.flipBook.bookContext.ctx = RunTime.flipBook.getContext();
	RunTime.requestBookInfo();
}
RunTime.loadState = function() {
	var bbv = true;
	var params = orc.utils.Util.getUrlParams();
	{
		var _g1 = 0, _g = params.length;
		while(_g1 < _g) {
			var i = _g1++;
			var item = params[i];
			if(item.key == "page") {
				var num = Std.parseInt(item.value);
				RunTime.defaultPageNum = num;
			}
			else if(item.key == "bbv") {
				if(item.value == "1") {
					bbv = true;
				}
				else if(item.value == "0") {
					bbv = false;
				}
			}
			else if(item.key == "pcode") {
				RunTime.pcode = item.value;
			}
		}
	}
	if(bbv == true) {
		RunTime.flipBook.showBottomBar();
	}
	else {
		RunTime.flipBook.hideBottomBar(null,false);
	}
}
RunTime.requestBookInfo = function() {
	orc.utils.Util.request(RunTime.urlBookinfo,function(data) {
		RunTime.bookInfo = Xml.parse(data);
		RunTime.loadBookInfo();
		RunTime.key = RunTime.calcKey(Std["int"](RunTime.book.pageWidth),Std["int"](RunTime.book.pageHeight));
		var defaultKey = "Pwd-Empty";
		if(RunTime.pcode.length > 0) {
			defaultKey = RunTime.decode64(RunTime.pcode);
		}
		var encode = RunTime.encryptKey(defaultKey,RunTime.key);
		if(encode == RunTime.book.password) {
			RunTime.afterRequestBookInfo();
		}
		else {
			RunTime.showPopupMaskLayer();
			RunTime.flipBook.cvsOthers.innerHTML = core.HtmlHelper.toInputPwdHtml();
		}
	});
}
RunTime.tryPwd = function(pwd) {
	var encode = RunTime.encryptKey(pwd,RunTime.key);
	if(encode == RunTime.book.password) {
		RunTime.pcode = StringTools.urlEncode(RunTime.encode64(pwd,false));
		RunTime.afterRequestBookInfo();
	}
	else {
		js.Lib.window.alert("Error password.");
	}
}
RunTime.afterRequestBookInfo = function() {
	RunTime.flipBook.cvsOthers.innerHTML = "";
	RunTime.clearPopupContents();
	RunTime.requestPages();
	RunTime.useAnalyticsUA(RunTime.book.analyticsUA,RunTime.book.bookId);
}
RunTime.requestPages = function() {
	orc.utils.Util.request(RunTime.urlPageInfo,function(data) {
		RunTime.pageInfo = Xml.parse(data);
		RunTime.loadPageInfo();
		RunTime.requestHotlinks();
		RunTime.requestContents();
		RunTime.requestVideos();
		RunTime.requestButtons();
	});
}
RunTime.requestHotlinks = function(onSuccess) {
	orc.utils.Util.request(RunTime.urlHotlinks,function(data) {
		var dom = new DOMParser();
		var ctx = new Xml2Html();
		RunTime.hotlinkInfo = dom.parseFromString(ctx.prepareXmlAsHtml(data),"text/xml");
		RunTime.loadHotlinks(ctx);
		if(RunTime.flipBook != null) {
			RunTime.flipBook.loadCtxHotlinks();
			RunTime.flipBook.bookContext.render();
		}
		if(onSuccess != null) onSuccess();
	});
}
RunTime.requestVideos = function(onSuccess) {
	orc.utils.Util.request(RunTime.urlVideos,function(data) {
		RunTime.videoInfo = Xml.parse(data);
		RunTime.loadVideos();
		if(RunTime.flipBook != null) {
			RunTime.flipBook.updateVideos();
			RunTime.flipBook.bookContext.render();
		}
		if(onSuccess != null) onSuccess();
	});
}
RunTime.requestButtons = function(onSuccess) {
	orc.utils.Util.request(RunTime.urlButtons,function(data) {
		RunTime.buttonInfo = Xml.parse(data);
		RunTime.loadButtons();
		if(RunTime.flipBook != null) {
			RunTime.flipBook.loadCtxButtons();
			RunTime.flipBook.bookContext.render();
		}
		if(onSuccess != null) onSuccess();
	});
}
RunTime.requestContents = function() {
	orc.utils.Util.request(RunTime.urlContents,function(data) {
		RunTime.contentInfo = Xml.parse(data);
	});
}
RunTime.requestSearch = function(invoke) {
	orc.utils.Util.request(RunTime.urlSearch,function(data) {
		var dom = new DOMParser();
		var ctx = new Xml2Html();
		RunTime.searchInfo = dom.parseFromString(ctx.prepareXmlAsHtml(data),"text/xml");
		RunTime.loadPageContents(ctx);
		if(invoke != null) {
			invoke(RunTime.book.pages);
		}
	});
}
RunTime.loadPageContents = function(ctx) {
	if(RunTime.searchInfo == null) return;
	var dom = RunTime.searchInfo;
	var pages = dom.getElementsByTagName("page");
	{
		var _g1 = 0, _g = pages.length;
		while(_g1 < _g) {
			var i = _g1++;
			var node = pages[i];
			var pageNumVal = node.getAttribute("pageNumber");
			var htmlText = null;
			var htmlTextDoms = node.getElementsByTagName("cdata");
			if(htmlTextDoms != null && htmlTextDoms.length > 0) {
				htmlText = StringTools.trim(htmlTextDoms[0].childNodes[0].nodeValue);
				htmlText = ctx.getCData(htmlText);
			}
			{
				var _g3 = 0, _g2 = RunTime.book.pages.length;
				while(_g3 < _g2) {
					var k = _g3++;
					var page = RunTime.book.pages[k];
					if(page.id == pageNumVal) {
						page.content = htmlText;
					}
				}
			}
		}
	}
}
RunTime.reload = function() {
	js.Lib.window.location.href = RunTime.flipBook.getFullUrl();
}
RunTime.loadBookInfo = function() {
	if(RunTime.bookInfo == null) return;
	var i = RunTime.bookInfo.elementsNamed("bookinfo");
	if(i.hasNext() == false) return;
	var node = i.next();
	var idVal = node.get("id");
	if(idVal == null) idVal = "";
	RunTime.book.bookId = idVal;
	RunTime.book.bookTitle = node.get("title");
	RunTime.book.bgColor = node.get("bgColor");
	RunTime.book.bgImageUrl = node.get("bgImage");
	RunTime.book.analyticsUA = node.get("analyticsUA");
	RunTime.book.password = node.get("password");
	if(RunTime.book.bgColor == "" || RunTime.book.bgColor == null) {
		RunTime.book.bgColor = "gray";
	}
	if(RunTime.book.bgColor != "" && RunTime.book.bgColor != null) {
		js.Lib.document.body.style.backgroundColor = RunTime.book.bgColor;
	}
	if(RunTime.book.bgImageUrl != "" && RunTime.book.bgImageUrl != null) {
		js.Lib.document.body.style.backgroundImage = "url(" + RunTime.book.bgImageUrl + ")";
		js.Lib.document.body.style.backgroundRepeat = "no-repeat";
		js.Lib.document.body.style.backgroundPosition = "center";
	}
	js.Lib.window.document.title = RunTime.book.bookTitle;
	var pageWidth = Std.parseFloat(node.get("pageWidth"));
	var pageHeight = Std.parseFloat(node.get("pageHeight"));
	RunTime.book.pageWidth = pageWidth;
	RunTime.book.pageHeight = pageHeight;
	var m = new orc.utils.ImageMetricHelper(pageWidth,pageHeight);
	var w = RunTime.clientWidth;
	var h = RunTime.clientHeight;
	var scale = m.getMaxFitScale(w,h);
	RunTime.imagePageWidth = pageWidth * scale;
	RunTime.imagePageHeight = pageHeight * scale;
	RunTime.pageScale = scale;
	var li = node.elementsNamed("bookLogo");
	if(li.hasNext() == true) {
		var lnode = li.next();
		RunTime.book.logoUrl = lnode.get("url");
		RunTime.book.logoHref = lnode.get("href");
	}
	if(RunTime.book.logoUrl != null && RunTime.book.logoUrl != "") {
		RunTime.flipBook.imgLogo.style.display = "inline";
		var obj = RunTime.flipBook.imgLogo;
		obj.src = RunTime.book.logoUrl;
		RunTime.flipBook.imgLogo.onclick = $closure(RunTime,"onLogoClick");
	}
	var bottomMenuIter = node.elementsNamed("bottommenu");
	if(bottomMenuIter.hasNext() == true) {
		var bottomMenuNode = bottomMenuIter.next();
		RunTime.book.menuAutoFlipVisible = RunTime.getMenuVisible(bottomMenuNode,"autoflip");
		RunTime.book.menuSearchVisible = RunTime.getMenuVisible(bottomMenuNode,"search");
		RunTime.book.menuTxtVisible = RunTime.getMenuVisible(bottomMenuNode,"txt");
		RunTime.book.menuZoomVisible = RunTime.getMenuVisible(bottomMenuNode,"zoom");
	}
	var leftMenuIter = node.elementsNamed("leftmenu");
	if(leftMenuIter.hasNext() == true) {
		var leftMenuNode = leftMenuIter.next();
		RunTime.book.menuTocVisible = RunTime.getMenuVisible(leftMenuNode,"toc");
		RunTime.book.menuThumbsVisible = RunTime.getMenuVisible(leftMenuNode,"thumbs");
	}
	RunTime.setMenuVisible(RunTime.flipBook.btnContents,RunTime.book.menuTocVisible);
	RunTime.setMenuVisible(RunTime.flipBook.btnThumbs,RunTime.book.menuThumbsVisible);
	RunTime.setMenuVisible(RunTime.flipBook.btnSearch,RunTime.book.menuSearchVisible);
	RunTime.setMenuVisible(RunTime.flipBook.btnAutoFlip,RunTime.book.menuAutoFlipVisible);
	RunTime.setMenuVisible(RunTime.flipBook.btnShowTxt,RunTime.book.menuTxtVisible);
	RunTime.setMenuVisible(RunTime.flipBook.btnZoom,RunTime.book.menuZoomVisible);
	RunTime.loadState();
}
RunTime.setMenuVisible = function(menu,visible) {
	if(visible == true) {
		menu.style.display = "inline";
	}
	else {
		RunTime.flipBook.menuParent.removeChild(menu);
	}
}
RunTime.getMenuVisible = function(parent,nodeName) {
	var li = parent.elementsNamed(nodeName);
	if(li.hasNext() == true) {
		var lnode = li.next();
		if(lnode.get("visible") == "false") return false;
	}
	return true;
}
RunTime.onLogoClick = function(e) {
	if(RunTime.book == null || RunTime.book.logoHref == null || RunTime.book.logoHref == "") {
		return;
	}
	js.Lib.window.location.href = RunTime.book.logoHref;
}
RunTime.loadPageInfo = function() {
	if(RunTime.pageInfo == null) return;
	var root = RunTime.pageInfo.firstElement();
	var val = root.get("preload");
	if(val.toLowerCase() == "true") {
		RunTime.enablePreload = true;
	}
	var i = root.elementsNamed("page");
	var num = 0;
	var numDouble = 0.1;
	while(i.hasNext() == true) {
		var node = i.next();
		var id = node.get("id");
		var source = node.get("source");
		var medium = node.get("medium");
		var thumb = node.get("thumb");
		if(medium == null || medium == "") {
			medium = "content/medium/page" + Std.string(num + 1) + ".jpg";
		}
		var page = new core.Page();
		page.id = id;
		page.num = num;
		page.numInDoubleMode = Std["int"](Math.round(numDouble));
		page.urlPage = medium;
		page.urlThumb = thumb;
		page.urlFullPage = source;
		RunTime.book.pages.push(page);
		numDouble += 0.5;
		num++;
	}
	RunTime.flipBook.setPageCount(RunTime.book.pages.length);
	RunTime.flipBook.setCurrentPage(RunTime.defaultPageNum + 1);
	RunTime.flipBook.loadPage(RunTime.defaultPageNum);
}
RunTime.loadHotlinks = function(ctx) {
	if(RunTime.hotlinkInfo == null) return;
	var dom = RunTime.hotlinkInfo;
	var links = dom.getElementsByTagName("hotlink");
	{
		var _g1 = 0, _g = links.length;
		while(_g1 < _g) {
			var i = _g1++;
			var node = links[i];
			var pageNumVal = node.getAttribute("page");
			var xVal = node.getAttribute("x");
			var yVal = node.getAttribute("y");
			var widthVal = node.getAttribute("width");
			var heightVal = node.getAttribute("height");
			var colorVal = node.getAttribute("color");
			var opacityVal = node.getAttribute("opacity");
			var destinationVal = node.getAttribute("destination");
			var typeVal = node.getAttribute("type");
			var popupWidthVal = node.getAttribute("popupWidth");
			var popupHeightVal = node.getAttribute("popupHeight");
			var youtubeIdVal = node.getAttribute("youtubeId");
			var htmlText = null;
			var htmlTextDoms = node.getElementsByTagName("cdata");
			if(htmlTextDoms != null && htmlTextDoms.length > 0) {
				htmlText = StringTools.trim(htmlTextDoms[0].childNodes[0].nodeValue);
				htmlText = ctx.getCData(htmlText);
			}
			var link = new core.HotLink();
			link.pageNum = Std.parseInt(pageNumVal) - 1;
			link.x = Std.parseFloat(xVal);
			link.y = Std.parseFloat(yVal);
			link.width = Std.parseFloat(widthVal);
			link.height = Std.parseFloat(heightVal);
			link.htmlText = htmlText;
			if(popupWidthVal != null) link.popupWidth = Std.parseInt(popupWidthVal);
			if(popupHeightVal != null) link.popupHeight = Std.parseInt(popupHeightVal);
			link.youtubeId = youtubeIdVal;
			link.type = typeVal == null?"":typeVal;
			if(colorVal != null) {
				colorVal = StringTools.replace(colorVal,"0x","#");
				colorVal = StringTools.replace(colorVal,"0X","#");
				link.color = colorVal;
			}
			if(opacityVal != null) link.opacity = Std.parseFloat(opacityVal);
			if(destinationVal != null) link.destination = destinationVal;
			RunTime.book.hotlinks.push(link);
		}
	}
}
RunTime.loadVideos = function() {
	if(RunTime.videoInfo == null) return;
	var i = RunTime.videoInfo.firstElement().elementsNamed("video");
	while(i.hasNext() == true) {
		var node = i.next();
		var pageNumVal = node.get("page");
		var xVal = node.get("x");
		var yVal = node.get("y");
		var widthVal = node.get("width");
		var heightVal = node.get("height");
		var autoPlayVal = node.get("autoPlay");
		var showControlVal = node.get("showControl");
		var autoRepeatVal = node.get("autoRepeat");
		var urlVal = node.get("url");
		var youtubeIdVal = node.get("youtubeId");
		var video = new core.VideoInfo();
		video.pageNum = Std.parseInt(pageNumVal) - 1;
		video.x = Std.parseFloat(xVal);
		video.y = Std.parseFloat(yVal);
		video.width = Std.parseFloat(widthVal);
		video.height = Std.parseFloat(heightVal);
		video.autoPlay = autoPlayVal == "true";
		video.showControl = showControlVal == "true";
		video.autoRepeat = autoRepeatVal == "true";
		video.url = urlVal;
		video.youtubeId = youtubeIdVal;
		RunTime.book.videos.push(video);
	}
}
RunTime.extractCData = function(txt) {
	if(txt == null) return null;
	var first = txt.indexOf("<![CDATA[");
	var last = txt.lastIndexOf("]]>");
	if(first < 0 || last < 0 || last < first) return null;
	return txt.substr(first + "<![CDATA[".length,last - first - "<![CDATA[".length);
}
RunTime.loadButtons = function() {
	if(RunTime.buttonInfo == null) return;
	var i = RunTime.buttonInfo.firstElement().elementsNamed("button");
	while(i.hasNext() == true) {
		var node = i.next();
		var pageNumVal = node.get("page");
		var xVal = node.get("x");
		var yVal = node.get("y");
		var widthVal = node.get("width");
		var heightVal = node.get("height");
		var imageVal = node.get("image");
		var typeVal = node.get("type");
		var popupWidthVal = node.get("popupWidth");
		var popupHeightVal = node.get("popupHeight");
		var youtubeIdVal = node.get("youtubeId");
		var destinationVal = node.get("destination");
		var htmlText = RunTime.extractCData(node.toString());
		var item = new core.ButtonInfo();
		item.pageNum = Std.parseInt(pageNumVal) - 1;
		item.x = Std.parseFloat(xVal);
		item.y = Std.parseFloat(yVal);
		item.width = Std.parseFloat(widthVal);
		item.height = Std.parseFloat(heightVal);
		item.htmlText = htmlText;
		if(popupWidthVal != null) item.popupWidth = Std.parseInt(popupWidthVal);
		if(popupHeightVal != null) item.popupHeight = Std.parseInt(popupHeightVal);
		item.youtubeId = youtubeIdVal;
		item.destination = destinationVal;
		item.type = typeVal == null?"":typeVal;
		item.image = imageVal;
		RunTime.book.buttons.push(item);
	}
}
RunTime.getInputAndJumpToPage = function() {
	RunTime.flipBook.stopFlip();
	var t = RunTime.flipBook.tbPage;
	var val = t.value;
	val = StringTools.trim(val);
	var num = RunTime.flipBook.currentPageNum;
	if(val != "") {
		num = Std.parseInt(val) - 1;
	}
	if(num < 0) num = 0;
	else if(num > RunTime.book.pages.length - 1) {
		num = RunTime.book.pages.length - 1;
	}
	RunTime.flipBook.tbPage.setAttribute("value",Std.string(num + 1));
	RunTime.flipBook.turnToPage(num);
	RunTime.flipBook.tbPage.blur();
}
RunTime.getPage = function(currentPageNum,pageOffset,useNewDrawParams) {
	if(useNewDrawParams == null) useNewDrawParams = true;
	if(pageOffset == null) pageOffset = 0;
	if(RunTime.book == null || RunTime.book.pages == null) return null;
	var num = currentPageNum + pageOffset;
	if(num < 0 || num > RunTime.book.pages.length - 1) return null;
	var page = RunTime.book.pages[num];
	page.pageOffset = pageOffset;
	if(useNewDrawParams == true) {
		page.drawParams = RunTime.getDrawParams();
	}
	return page;
}
RunTime.getDrawParams = function(layout) {
	if(layout == null) layout = 0;
	var dp = new core.DrawParams();
	var im = new orc.utils.ImageMetricHelper(RunTime.book.pageWidth,RunTime.book.pageHeight);
	var cw = RunTime.clientWidth;
	if(layout != 0) {
		cw = 0.5 * cw;
	}
	var ch = RunTime.clientHeight;
	var scale = im.getMaxFitScale(cw,ch);
	var dw = scale * RunTime.book.pageWidth;
	var dh = scale * RunTime.book.pageHeight;
	var dx = 0.5 * (cw - dw);
	if(layout != 0) {
		dx = layout < 0?cw - dw:cw;
	}
	var dy = 0.5 * (ch - dh);
	var sx = 0;
	var sy = 0;
	var sw = RunTime.book.pageWidth;
	var sh = RunTime.book.pageHeight;
	dp.sx = sx;
	dp.sy = sy;
	dp.sw = sw;
	dp.sh = sh;
	dp.dx = dx;
	dp.dy = dy;
	dp.dw = dw;
	dp.dh = dh;
	return dp;
}
RunTime.saveLocal = function(key,val) {
	null;
}
RunTime.getLocal = function(key) {
	return "";
}
RunTime.setUpdateFlag = function(bookId) {
	var prefix = bookId == null?RunTime.book.bookId:bookId;
	RunTime.saveLocal(prefix + "-" + "uploadFlag","1");
}
RunTime.getAndResetUpdateFlag = function() {
	var val = RunTime.getLocal(RunTime.book.bookId + "-" + "uploadFlag");
	RunTime.saveLocal(RunTime.book.bookId + "-" + "uploadFlag","");
	return val == "1";
}
RunTime.saveCurrentPageNum = function() {
	RunTime.savePageNum(Std.string(RunTime.flipBook.getCurrentPageNum()));
}
RunTime.savePageNum = function(val,bookId) {
	var prefix = bookId == null?RunTime.book.bookId:bookId;
	RunTime.saveLocal(prefix + "-" + "page",val);
}
RunTime.getAndResetSavedPageNum = function() {
	var val = RunTime.getLocal(RunTime.book.bookId + "-" + "page");
	RunTime.savePageNum("");
	if(val == null || val == "") return 0;
	else {
		return Std.parseInt(val);
	}
}
RunTime.saveBottomBarVisible = function(val) {
	if(val == true) {
		RunTime.saveLocal(RunTime.book.bookId + "-" + "bottomBarVisible","true");
	}
	else {
		RunTime.saveLocal(RunTime.book.bookId + "-" + "bottomBarVisible","false");
	}
}
RunTime.getBottomBarVisible = function() {
	return RunTime.getLocal(RunTime.book.bookId + "-" + "bottomBarVisible") == "true";
}
RunTime.encrypt = function(src) {
	return RunTime.encryptKey(src,RunTime.key);
}
RunTime.encryptKey = function(src,key) {
	var n = 0;
	var rtn = "";
	{
		var _g1 = 0, _g = src.length - 1;
		while(_g1 < _g) {
			var i = _g1++;
			var c = src.charCodeAt(i) + key.charCodeAt(n);
			var s = String.fromCharCode(c);
			rtn += s;
			n++;
			if(n >= key.length) n = 0;
		}
	}
	if(src.length > 0) {
		rtn = rtn + src.substr(src.length - 1);
	}
	return RunTime.encode64(rtn);
}
RunTime.encode64 = function(txt,padding) {
	if(padding == null) padding = true;
	var bytes = haxe.io.Bytes.alloc(txt.length);
	{
		var _g1 = 0, _g = txt.length;
		while(_g1 < _g) {
			var i = _g1++;
			var c = txt.cca(i);
			bytes.b[i] = c & 255;
		}
	}
	var c = new haxe.BaseCode(haxe.io.Bytes.ofString("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"));
	var base64 = c.encodeBytes(bytes).toString();
	if(padding == true) {
		var remainder = base64.length % 4;
		if(remainder > 1) {
			base64 += "=";
		}
		if(remainder == 2) {
			base64 += "=";
		}
	}
	return base64;
}
RunTime.decode64 = function(txt) {
	var paddingSize = -1;
	if(txt.charAt(txt.length - 2) == "=") {
		paddingSize = 2;
	}
	else if(txt.charAt(txt.length - 1) == "=") {
		paddingSize = 1;
	}
	if(paddingSize != -1) {
		txt = txt.substr(0,txt.length - paddingSize);
	}
	var c = new haxe.BaseCode(haxe.io.Bytes.ofString("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"));
	return c.decodeString(txt);
}
RunTime.calcKey = function(w,h) {
	var val = Std.string(w * h);
	val = val.substr(val.length - 3) + val.substr(0,2);
	var n = "";
	{
		var _g1 = 0, _g = val.length;
		while(_g1 < _g) {
			var i = _g1++;
			var c = Std["int"](val.charCodeAt(i) / 2);
			n = n + StringTools.hex(c);
		}
	}
	return n.toUpperCase();
}
RunTime.clearPopupContents = function() {
	js.Lib.document.getElementById("maskPopup").style.display = "none";
	js.Lib.document.getElementById("cvsOthers").innerHTML = "";
}
RunTime.clearAudio = function() {
	js.Lib.document.getElementById("cvsAudio").innerHTML = "";
}
RunTime.showPopupMaskLayer = function() {
	js.Lib.document.getElementById("maskPopup").style.display = "inline";
}
RunTime.playAudio = function() {
	var item = js.Lib.document.getElementById("cvsAudio").getElementsByTagName("audio")[0];
	item.play();
}
RunTime.playVideo = function() {
	var item = js.Lib.document.getElementById("cvsOthers").getElementsByTagName("video")[0];
	item.play();
}
RunTime.setOffset = function(dom,left,top) {
	var l = Math.round(left);
	var t = Math.round(top);
	dom.style.left = Std.string(l) + "px";
	dom.style.top = Std.string(t) + "px";
}
RunTime.tracker = null;
RunTime.trackerId = null;
RunTime.useAnalyticsUA = function(ua,id) {
	if(RunTime.isNullOrEmpty(ua)) return;
	RunTime.trackerId = id;
	var gat = _gat;
	RunTime.tracker = gat._getTracker(ua);
	RunTime.tracker._initData();
}
RunTime.log = function(action,msg) {
	if(RunTime.isNullOrEmpty(msg)) return;
	if(RunTime.useGoogleUaAsLogViewer == false) {
		js.Lib.alert(action + ":" + msg);
		return;
	}
	if(RunTime.tracker) {
		RunTime.tracker._trackPageview(RunTime.trackerId + "/" + action + "/" + msg);
	}
}
RunTime.logPageView = function(pageNum) {
	if(pageNum > 0) {
		RunTime.log("page",Std.string(pageNum));
	}
}
RunTime.logClickLink = function(url,url2) {
	if(RunTime.isNullOrEmpty(url) && RunTime.isNullOrEmpty(url2)) return;
	RunTime.log("link",RunTime.isNullOrEmpty(url) == false?url:url2);
}
RunTime.logVideoView = function(url,url2) {
	if(RunTime.isNullOrEmpty(url) && RunTime.isNullOrEmpty(url2)) return;
	url = RunTime.removePrefix(url);
	RunTime.log("video",RunTime.isNullOrEmpty(url) == false?url:url2);
}
RunTime.isNullOrEmpty = function(txt) {
	return txt == null || txt == "" || txt == "undefined";
}
RunTime.logAudioView = function(url) {
	if(url == null || url == "") return;
	url = RunTime.removePrefix(url);
	RunTime.log("audio",url);
}
RunTime.logSearch = function(keyword) {
	if(keyword == null || keyword == "") return;
	RunTime.log("search",keyword);
}
RunTime.removePrefix = function(url) {
	if(url == null || url == "") return url;
	else if(url.indexOf("http") == 0) return url;
	else {
		var i = url.lastIndexOf("/");
		return url.substr(i + 1);
	}
}
RunTime.prototype.__class__ = RunTime;
core.DrawParams = function(p) { if( p === $_ ) return; {
	null;
}}
core.DrawParams.__name__ = ["core","DrawParams"];
core.DrawParams.prototype.sx = null;
core.DrawParams.prototype.sy = null;
core.DrawParams.prototype.sw = null;
core.DrawParams.prototype.sh = null;
core.DrawParams.prototype.dx = null;
core.DrawParams.prototype.dy = null;
core.DrawParams.prototype.dw = null;
core.DrawParams.prototype.dh = null;
core.DrawParams.prototype.dxi = function() {
	return Math.round(this.dx);
}
core.DrawParams.prototype.dyi = function() {
	return Math.round(this.dy);
}
core.DrawParams.prototype.dwi = function() {
	return Math.round(this.dw);
}
core.DrawParams.prototype.dhi = function() {
	return Math.round(this.dh);
}
core.DrawParams.prototype.scaleX = function() {
	return this.dw / this.sw;
}
core.DrawParams.prototype.scaleY = function() {
	return this.dh / this.sh;
}
core.DrawParams.prototype.toString = function() {
	return Std.string(this.sx) + "," + Std.string(this.sy) + "," + Std.string(this.sw) + "," + Std.string(this.sh) + "," + Std.string(this.dx) + "," + Std.string(this.dy) + "," + Std.string(this.dw) + "," + Std.string(this.dh);
}
core.DrawParams.prototype.sliceLeft = function(ratio,xOffset) {
	if(xOffset == null) xOffset = 0;
	if(ratio < 0) ratio = 0;
	else if(ratio > 1) ratio = 1;
	var dp = new core.DrawParams();
	dp.sx = this.sx;
	dp.sy = this.sy;
	dp.dx = this.dx + xOffset;
	dp.dy = this.dy;
	dp.sw = this.sw * ratio;
	dp.sh = this.sh;
	dp.dw = this.dw * ratio;
	dp.dh = this.dh;
	return dp;
}
core.DrawParams.prototype.sliceRight = function(ratio,xOffset) {
	if(xOffset == null) xOffset = 0;
	if(ratio < 0) ratio = 0;
	else if(ratio > 1) ratio = 1;
	var dp = new core.DrawParams();
	dp.sx = this.sx + this.sw * (1 - ratio);
	dp.sy = this.sy;
	dp.dx = this.dx + this.dw * (1 - ratio) + xOffset;
	dp.dy = this.dy;
	dp.sw = this.sw * ratio;
	dp.sh = this.sh;
	dp.dw = this.dw * ratio;
	dp.dh = this.dh;
	return dp;
}
core.DrawParams.prototype.__class__ = core.DrawParams;
Zoom = function() { }
Zoom.__name__ = ["Zoom"];
Zoom.pageWidth = null;
Zoom.pageHeight = null;
Zoom.xScale = null;
Zoom.yScale = null;
Zoom.cvsZoom = null;
Zoom.cvsZoomDom = null;
Zoom.mask = null;
Zoom.maskPopup = null;
Zoom.img = null;
Zoom.clientWidth = null;
Zoom.clientHeight = null;
Zoom.getContext = function() {
	return Zoom.cvsZoom.getContext("2d");
}
Zoom.Load = function() {
	Zoom.cvsZoomDom = js.Lib.document.getElementById("cvsZoom");
	Zoom.mask = js.Lib.document.getElementById("mask");
	Zoom.maskPopup = js.Lib.document.getElementById("maskPopup");
	Zoom.maskPopup.onclick = $closure(Zoom,"forbidden");
	Zoom.maskPopup.ontouchstart = $closure(Zoom,"forbidden");
	Zoom.maskPopup.ontouchmove = $closure(Zoom,"forbidden");
	Zoom.maskPopup.ontouchend = $closure(Zoom,"forbidden");
	Zoom.maskPopup.ontouchcancel = $closure(Zoom,"forbidden");
	Zoom.maskPopup.ongestureend = $closure(Zoom,"forbidden");
	Zoom.maskPopup.ongesturestart = $closure(Zoom,"forbidden");
	Zoom.maskPopup.ongesturechange = $closure(Zoom,"forbidden");
	Zoom.maskPopup.onscroll = $closure(Zoom,"forbidden");
	Zoom.maskPopup.onmousewheel = $closure(Zoom,"forbidden");
	var dy = Zoom.cvsZoomDom;
	Zoom.cvsZoom = dy;
	Zoom.mask.ontouchstart = $closure(Zoom,"onZoom");
	Zoom.clientWidth = js.Lib.window.document.body.clientWidth;
	Zoom.clientHeight = js.Lib.window.document.body.clientHeight;
	RunTime.clientWidth = Zoom.clientWidth;
	RunTime.clientHeight = Zoom.clientHeight;
	var params = orc.utils.Util.getUrlParams();
	{
		var _g1 = 0, _g = params.length;
		while(_g1 < _g) {
			var i = _g1++;
			var item = params[i];
			if(item.key == "img") {
				Zoom.imgSrc = item.value;
			}
			else if(item.key == "bookId") {
				Zoom.bookId = item.value;
			}
			else if(item.key == "page") {
				Zoom.pageNum = item.value;
			}
			else if(item.key == "pw") {
				Zoom.pageWidth = Std.parseFloat(item.value);
			}
			else if(item.key == "ph") {
				Zoom.pageHeight = Std.parseFloat(item.value);
			}
			else if(item.key == "bookTitle") {
				Zoom.bookTitle = item.value;
				Zoom.bookTitle = StringTools.urlDecode(Zoom.bookTitle);
			}
			else if(item.key == "bbv") {
				Zoom.bbv = item.value;
			}
			else if(item.key == "ua") {
				Zoom.analyticsUA = item.value;
			}
			else if(item.key == "pcode") {
				Zoom.pcode = item.value;
			}
		}
	}
	js.Lib.document.title = Zoom.bookTitle + " - Page " + Std.string(Std.parseInt(Zoom.pageNum) + 1);
	Zoom.img = new core.Html5Image(Zoom.imgSrc,$closure(Zoom,"onLoadImage"));
	RunTime.useAnalyticsUA(Zoom.analyticsUA,Zoom.bookId);
	RunTime.logPageView(Std.parseInt(Zoom.pageNum) + 1);
}
Zoom.forbidden = function(e) {
	e.stopPropagation();
	e.preventDefault();
}
Zoom.onLoadImage = function() {
	var w = Zoom.img.image.width;
	var h = Zoom.img.image.height;
	Zoom.cvsZoom.width = Std["int"](Math.max(Zoom.pageWidth,Math.max(w,Zoom.clientWidth)));
	Zoom.cvsZoom.height = Std["int"](Math.max(Zoom.pageHeight,Math.max(h,Zoom.clientHeight)));
	Zoom.mask.style.width = Std.string(Zoom.cvsZoom.width) + "px";
	Zoom.mask.style.height = Std.string(Zoom.cvsZoom.height) + "px";
	Zoom.maskPopup.style.width = Std.string(Zoom.cvsZoom.width) + "px";
	Zoom.maskPopup.style.height = Std.string(Zoom.cvsZoom.height) + "px";
	Zoom.xOffset = 0.5 * (Zoom.cvsZoom.width - Math.max(Zoom.img.image.width,Zoom.pageWidth));
	Zoom.yOffset = 0.5 * (Zoom.cvsZoom.height - Math.max(Zoom.img.image.height,Zoom.pageHeight));
	Zoom.xScale = w / Zoom.pageWidth;
	Zoom.yScale = h / Zoom.pageHeight;
	Zoom.draw();
	RunTime.requestHotlinks($closure(Zoom,"loadHotlinks"));
	RunTime.requestButtons($closure(Zoom,"loadButtons"));
	RunTime.requestVideos($closure(Zoom,"loadVideos"));
}
Zoom.draw = function() {
	var ctx = Zoom.getContext();
	var dp = Zoom.getDrawParams();
	ctx.drawImage(Zoom.img.image,dp.sx,dp.sy,dp.sw,dp.sh,dp.dx,dp.dy,dp.dw,dp.dh);
}
Zoom.getDrawParams = function() {
	var dp = new core.DrawParams();
	dp.sx = 0;
	dp.sy = 0;
	dp.sw = Zoom.img.image.width;
	dp.sh = Zoom.img.image.height;
	dp.dx = Zoom.xOffset;
	dp.dy = Zoom.yOffset;
	dp.dw = Math.max(Zoom.pageWidth,dp.sw);
	dp.dh = Math.max(Zoom.pageHeight,dp.sh);
	return dp;
}
Zoom.loadHotlinks = function() {
	var list = RunTime.book.hotlinks;
	{
		var _g1 = 0, _g = list.length;
		while(_g1 < _g) {
			var i = _g1++;
			var item = list[i];
			if(Std.string(item.pageNum) == Zoom.pageNum) {
				Zoom.hotlinks.push(item);
			}
		}
	}
	Zoom.renderHotlinks();
}
Zoom.loadVideos = function() {
	var list = RunTime.book.videos;
	{
		var _g1 = 0, _g = list.length;
		while(_g1 < _g) {
			var i = _g1++;
			var item = list[i];
			if(Std.string(item.pageNum) == Zoom.pageNum) {
				Zoom.videos.push(item);
			}
		}
	}
	Zoom.renderVideos();
}
Zoom.loadButtons = function() {
	var list = RunTime.book.buttons;
	{
		var _g1 = 0, _g = list.length;
		while(_g1 < _g) {
			var i = _g1++;
			var item = list[i];
			if(Std.string(item.pageNum) == Zoom.pageNum) {
				Zoom.buttons.push(item);
			}
		}
	}
	Zoom.renderButtons();
}
Zoom.renderHotlinks = function() {
	var list = Zoom.hotlinks;
	var ctx = Zoom.getContext();
	{
		var _g1 = 0, _g = list.length;
		while(_g1 < _g) {
			var i = _g1++;
			var item = list[i];
			Zoom.renderHotlink(ctx,item);
		}
	}
}
Zoom.renderHotlink = function(ctx,link) {
	link.loadToRect(ctx,Zoom.xOffset + link.x * Zoom.xScale,Zoom.yOffset + link.y * Zoom.yScale,link.width * Zoom.xScale,link.height * Zoom.yScale);
}
Zoom.renderVideos = function() {
	var dom = js.Lib.document.getElementById("cvsVideo");
	{
		var _g1 = 0, _g = Zoom.videos.length;
		while(_g1 < _g) {
			var i = _g1++;
			var item = Zoom.videos[i];
			item.x = item.x * Zoom.xScale;
			if(item.youtubeId == null || item.youtubeId == "") {
				dom.innerHTML += core.HtmlHelper.toRectVideoHtml(item,Zoom.xOffset + item.x * Zoom.xScale,Zoom.yOffset + item.y * Zoom.yScale,item.width * Zoom.xScale,item.height * Zoom.yScale);
			}
			else {
				dom.innerHTML += core.HtmlHelper.toRectYoutubeVideoHtml(item,Zoom.xOffset + item.x * Zoom.xScale,Zoom.yOffset + item.y * Zoom.yScale,item.width * Zoom.xScale,item.height * Zoom.yScale);
			}
		}
	}
}
Zoom.renderButtons = function() {
	var list = Zoom.buttons;
	var ctx = Zoom.getContext();
	{
		var _g1 = 0, _g = list.length;
		while(_g1 < _g) {
			var i = _g1++;
			var item = list[i];
			item.loadToContext2DRect(ctx,Zoom.xOffset + item.x * Zoom.xScale,Zoom.yOffset + item.y * Zoom.yScale,item.width * Zoom.xScale,item.height * Zoom.yScale);
		}
	}
}
Zoom.lastTouchTime = null;
Zoom.onZoom = function(e) {
	var date = Date.now();
	if(Zoom.lastTouchTime != null) {
		var lastTime = Zoom.lastTouchTime.getTime();
		var newTime = date.getTime();
		if(newTime - lastTime < RunTime.doubleClickIntervalMs) {
			Zoom.lastTouchTime = null;
			Zoom.zoomOut();
			return;
		}
	}
	Zoom.lastTouchTime = date;
	var obj = e;
	var touch = obj.touches[0];
	if(obj.touches.length > 1) {
		Zoom.zoomOut();
	}
	else {
		Zoom.onClick(e);
	}
}
Zoom.zoomOut = function(num) {
	if(num == null) num = -1;
	if(num == -1 || num == null) {
		num = Std.parseInt(Zoom.pageNum);
	}
	js.Lib.window.location.href = RunTime.urlIndex + "?page=" + Std.string(num) + "&bbv=" + Zoom.bbv + "&pcode=" + Zoom.pcode;
}
Zoom.onClick = function(e) {
	var match = null;
	var list = Zoom.hotlinks;
	var obj = e;
	var touch = obj.touches[0];
	var xx = touch.screenX;
	var yy = touch.screenY;
	Zoom.popupXOffset = xx - touch.clientX;
	Zoom.popupYOffset = yy - touch.clientY;
	{
		var _g1 = 0, _g = list.length;
		while(_g1 < _g) {
			var i = _g1++;
			var link = list[i];
			if(xx >= Zoom.xOffset + link.x * Zoom.xScale && xx <= Zoom.xOffset + link.x * Zoom.xScale + link.width * Zoom.xScale && yy >= Zoom.yOffset + link.y * Zoom.yScale && yy <= Zoom.yOffset + link.y * Zoom.yScale + link.height * Zoom.yScale) {
				match = link;
				break;
			}
		}
	}
	Zoom.invokeClickHotlink(match);
	var matchButton = null;
	{
		var _g1 = 0, _g = Zoom.buttons.length;
		while(_g1 < _g) {
			var i = _g1++;
			var button = Zoom.buttons[i];
			if(xx >= Zoom.xOffset + button.x * Zoom.xScale && xx <= Zoom.xOffset + button.x * Zoom.xScale + button.width * Zoom.xScale && yy >= Zoom.yOffset + button.y * Zoom.yScale && yy <= Zoom.yOffset + button.y * Zoom.yScale + button.height * Zoom.yScale) {
				matchButton = button;
				break;
			}
		}
	}
	Zoom.invokeClickButton(matchButton);
}
Zoom.invokeClickHotlink = function(link) {
	if(link == null) return;
	link.click(Zoom.popupXOffset,Zoom.popupYOffset);
}
Zoom.invokeClickButton = function(item) {
	if(item == null) return;
	item.click(Zoom.popupXOffset,Zoom.popupYOffset);
}
Zoom.prototype.__class__ = Zoom;
orc.utils.UrlParam = function(p) { if( p === $_ ) return; {
	null;
}}
orc.utils.UrlParam.__name__ = ["orc","utils","UrlParam"];
orc.utils.UrlParam.prototype.key = null;
orc.utils.UrlParam.prototype.value = null;
orc.utils.UrlParam.prototype.__class__ = orc.utils.UrlParam;
core.ButtonInfo = function(p) { if( p === $_ ) return; {
	this.pageLayoutType = 0;
}}
core.ButtonInfo.__name__ = ["core","ButtonInfo"];
core.ButtonInfo.prototype.pageNum = null;
core.ButtonInfo.prototype.x = null;
core.ButtonInfo.prototype.y = null;
core.ButtonInfo.prototype.width = null;
core.ButtonInfo.prototype.height = null;
core.ButtonInfo.prototype.destination = null;
core.ButtonInfo.prototype.htmlText = null;
core.ButtonInfo.prototype.type = null;
core.ButtonInfo.prototype.image = null;
core.ButtonInfo.prototype.popupWidth = null;
core.ButtonInfo.prototype.popupHeight = null;
core.ButtonInfo.prototype.youtubeId = null;
core.ButtonInfo.prototype.dp = null;
core.ButtonInfo.prototype._imagePage = null;
core.ButtonInfo.prototype.loaded = null;
core.ButtonInfo.prototype.ctx = null;
core.ButtonInfo.prototype.pageLayoutType = null;
core.ButtonInfo.prototype.getDrawParams = function() {
	return RunTime.getDrawParams(this.pageLayoutType);
}
core.ButtonInfo.prototype.getImagePage = function(onloadFunc) {
	if(this._imagePage != null) return this._imagePage;
	var img = new Image();
	img.src = this.image;
	img.onload = onloadFunc;
	this._imagePage = img;
	return this._imagePage;
}
core.ButtonInfo.prototype.loadToContext2D = function(ctx) {
	this.ctx = ctx;
	if(this._imagePage == null) {
		var self = this;
		this.getImagePage(function() {
			self.loaded = true;
			self.loadToContext2D(self.ctx);
		});
	}
	if(this.loaded == true) {
		if(this.dp == null) this.dp = this.getDrawParams();
		var xx = this.dp.dx + (this.x - this.dp.sx) * this.dp.scaleX();
		var yy = this.dp.dy + (this.y - this.dp.sy) * this.dp.scaleY();
		var ww = this.width * this.dp.scaleX();
		var hh = this.height * this.dp.scaleY();
		this.loadToRect(ctx,xx,yy,ww,hh);
	}
}
core.ButtonInfo.prototype.loadToContext2DRect = function(ctx,x,y,w,h) {
	this.ctx = ctx;
	if(this._imagePage == null) {
		var self = this;
		this.getImagePage(function() {
			self.loaded = true;
			self.loadToContext2DRect(self.ctx,self.x,self.y,self.width,self.height);
		});
	}
	if(this.loaded == true) {
		this.loadToRect(ctx,x,y,this.width,this.height);
	}
}
core.ButtonInfo.prototype.loadToRect = function(ctx,x,y,w,h) {
	if(w > 0 && h > 0) {
		ctx.drawImage(this._imagePage,0,0,this._imagePage.width,this._imagePage.height,x,y,w,h);
	}
}
core.ButtonInfo.prototype.hitTest = function(mouseX,mouseY) {
	if(this.type == "none") return false;
	if(this.dp == null) this.dp = this.getDrawParams();
	var xx = this.dp.dx + (this.x - this.dp.sx) * this.dp.scaleX();
	var yy = this.dp.dy + (this.y - this.dp.sy) * this.dp.scaleY();
	var ww = this.width * this.dp.scaleX();
	var hh = this.height * this.dp.scaleY();
	var result = mouseX >= xx && mouseY >= yy && mouseX <= xx + ww && mouseY <= yy + hh;
	return result;
}
core.ButtonInfo.prototype.click = function(popupXOffset,popupYOffset) {
	if(popupYOffset == null) popupYOffset = 0;
	if(popupXOffset == null) popupXOffset = 0;
	switch(this.type) {
	case "":{
		if(this.destination != null) {
			if(this.destination.indexOf("page:") == 0) {
				var val = this.destination.substr(5);
				var num = Std.parseInt(val);
				if(RunTime.flipBook != null) {
					RunTime.flipBook.turnToPage(num - 1);
				}
				else {
					Zoom.zoomOut(num - 1);
				}
			}
			else if(this.destination.indexOf("mailto:") == 0) {
				RunTime.logClickLink(this.destination);
				js.Lib.window.location.href = this.destination;
			}
			else {
				RunTime.logClickLink(this.destination);
				js.Lib.window.location.href = this.destination;
			}
		}
	}break;
	case "image":{
		RunTime.showPopupMaskLayer();
		RunTime.setOffset(js.Lib.document.getElementById("cvsOthers"),popupXOffset,popupYOffset);
		core.HtmlHelper.toPopupImageHtml(this,function(txt) {
			js.Lib.document.getElementById("cvsOthers").innerHTML = txt;
		});
		RunTime.logClickLink(this.destination);
	}break;
	case "video":{
		RunTime.showPopupMaskLayer();
		RunTime.setOffset(js.Lib.document.getElementById("cvsOthers"),popupXOffset,popupYOffset);
		js.Lib.document.getElementById("cvsOthers").innerHTML = core.HtmlHelper.toPopupVideoHtml(this);
		RunTime.playVideo();
		RunTime.logVideoView(this.destination,this.youtubeId);
	}break;
	case "audio":{
		js.Lib.document.getElementById("cvsAudio").innerHTML = core.HtmlHelper.toPopupAudioHtml(this);
		RunTime.logAudioView(this.destination);
		RunTime.playAudio();
	}break;
	case "message":{
		RunTime.showPopupMaskLayer();
		RunTime.setOffset(js.Lib.document.getElementById("cvsOthers"),popupXOffset,popupYOffset);
		js.Lib.document.getElementById("cvsOthers").innerHTML = core.HtmlHelper.toPopupHtml(this);
	}break;
	case "message-hover":{
		RunTime.showPopupMaskLayer();
		RunTime.setOffset(js.Lib.document.getElementById("cvsOthers"),popupXOffset,popupYOffset);
		js.Lib.document.getElementById("cvsOthers").innerHTML = core.HtmlHelper.toPopupHtml(this);
	}break;
	}
}
core.ButtonInfo.prototype.__class__ = core.ButtonInfo;
Hash = function(p) { if( p === $_ ) return; {
	this.h = {}
	if(this.h.__proto__ != null) {
		this.h.__proto__ = null;
		delete(this.h.__proto__);
	}
	else null;
}}
Hash.__name__ = ["Hash"];
Hash.prototype.h = null;
Hash.prototype.set = function(key,value) {
	this.h["$" + key] = value;
}
Hash.prototype.get = function(key) {
	return this.h["$" + key];
}
Hash.prototype.exists = function(key) {
	try {
		key = "$" + key;
		return this.hasOwnProperty.call(this.h,key);
	}
	catch( $e0 ) {
		{
			var e = $e0;
			{
				
				for(var i in this.h)
					if( i == key ) return true;
			;
				return false;
			}
		}
	}
}
Hash.prototype.remove = function(key) {
	if(!this.exists(key)) return false;
	delete(this.h["$" + key]);
	return true;
}
Hash.prototype.keys = function() {
	var a = new Array();
	
			for(var i in this.h)
				a.push(i.substr(1));
		;
	return a.iterator();
}
Hash.prototype.iterator = function() {
	return { ref : this.h, it : this.keys(), hasNext : function() {
		return this.it.hasNext();
	}, next : function() {
		var i = this.it.next();
		return this.ref["$" + i];
	}};
}
Hash.prototype.toString = function() {
	var s = new StringBuf();
	s.b[s.b.length] = "{";
	var it = this.keys();
	{ var $it0 = it;
	while( $it0.hasNext() ) { var i = $it0.next();
	{
		s.b[s.b.length] = i;
		s.b[s.b.length] = " => ";
		s.b[s.b.length] = Std.string(this.get(i));
		if(it.hasNext()) s.b[s.b.length] = ", ";
	}
	}}
	s.b[s.b.length] = "}";
	return s.b.join("");
}
Hash.prototype.__class__ = Hash;
Main = function() { }
Main.__name__ = ["Main"];
Main.main = function() {
	if(js.Lib.document.getElementById("cvsBook") == null) {
		Zoom.Load();
	}
	else {
		RunTime.init();
	}
}
Main.testCss = function() {
	var t = new core.Tweener();
	var max = 20;
	var cvs = js.Lib.document.getElementById("img");
	t.onChange = function(count) {
		var l = Std.string(count * 30);
		cvs.style.left = l;
	}
	t.start(max);
}
Main.prototype.__class__ = Main;
$_ = {}
js.Boot.__res = {}
js.Boot.__init();
{
	Xml.Element = "element";
	Xml.PCData = "pcdata";
	Xml.CData = "cdata";
	Xml.Comment = "comment";
	Xml.DocType = "doctype";
	Xml.Prolog = "prolog";
	Xml.Document = "document";
}
{
	var d = Date;
	d.now = function() {
		return new Date();
	}
	d.fromTime = function(t) {
		var d1 = new Date();
		d1["setTime"](t);
		return d1;
	}
	d.fromString = function(s) {
		switch(s.length) {
		case 8:{
			var k = s.split(":");
			var d1 = new Date();
			d1["setTime"](0);
			d1["setUTCHours"](k[0]);
			d1["setUTCMinutes"](k[1]);
			d1["setUTCSeconds"](k[2]);
			return d1;
		}break;
		case 10:{
			var k = s.split("-");
			return new Date(k[0],k[1] - 1,k[2],0,0,0);
		}break;
		case 19:{
			var k = s.split(" ");
			var y = k[0].split("-");
			var t = k[1].split(":");
			return new Date(y[0],y[1] - 1,y[2],t[0],t[1],t[2]);
		}break;
		default:{
			throw "Invalid date format : " + s;
		}break;
		}
	}
	d.prototype["toString"] = function() {
		var date = this;
		var m = date.getMonth() + 1;
		var d1 = date.getDate();
		var h = date.getHours();
		var mi = date.getMinutes();
		var s = date.getSeconds();
		return date.getFullYear() + "-" + (m < 10?"0" + m:"" + m) + "-" + (d1 < 10?"0" + d1:"" + d1) + " " + (h < 10?"0" + h:"" + h) + ":" + (mi < 10?"0" + mi:"" + mi) + ":" + (s < 10?"0" + s:"" + s);
	}
	d.prototype.__class__ = d;
	d.__name__ = ["Date"];
}
{
	String.prototype.__class__ = String;
	String.__name__ = ["String"];
	Array.prototype.__class__ = Array;
	Array.__name__ = ["Array"];
	Int = { __name__ : ["Int"]};
	Dynamic = { __name__ : ["Dynamic"]};
	Float = Number;
	Float.__name__ = ["Float"];
	Bool = { __ename__ : ["Bool"]};
	Class = { __name__ : ["Class"]};
	Enum = { };
	Void = { __ename__ : ["Void"]};
}
{
	Math.__name__ = ["Math"];
	Math.NaN = Number["NaN"];
	Math.NEGATIVE_INFINITY = Number["NEGATIVE_INFINITY"];
	Math.POSITIVE_INFINITY = Number["POSITIVE_INFINITY"];
	Math.isFinite = function(i) {
		return isFinite(i);
	}
	Math.isNaN = function(i) {
		return isNaN(i);
	}
}
{
	js.Lib.document = document;
	js.Lib.window = window;
	onerror = function(msg,url,line) {
		var f = js.Lib.onerror;
		if( f == null )
			return false;
		return f(msg,[url+":"+line]);
	}
}
{
	js["XMLHttpRequest"] = window.XMLHttpRequest?XMLHttpRequest:window.ActiveXObject?function() {
		try {
			return new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch( $e0 ) {
			{
				var e = $e0;
				{
					try {
						return new ActiveXObject("Microsoft.XMLHTTP");
					}
					catch( $e1 ) {
						{
							var e1 = $e1;
							{
								throw "Unable to create XMLHttpRequest object.";
							}
						}
					}
				}
			}
		}
	}:(function($this) {
		var $r;
		throw "Unable to create XMLHttpRequest object.";
		return $r;
	}(this));
}
Xml.enode = new EReg("^<([a-zA-Z0-9:_-]+)","");
Xml.ecdata = new EReg("^<!\\[CDATA\\[","i");
Xml.edoctype = new EReg("^<!DOCTYPE ","i");
Xml.eend = new EReg("^</([a-zA-Z0-9:_-]+)>","");
Xml.epcdata = new EReg("^[^<]+","");
Xml.ecomment = new EReg("^<!--","");
Xml.eprolog = new EReg("^<\\?[^\\?]+\\?>","");
Xml.eattribute = new EReg("^\\s*([a-zA-Z0-9:_-]+)\\s*=\\s*([\"'])([^\\2]*?)\\2","");
Xml.eclose = new EReg("^[ \r\n\t]*(>|(/>))","");
Xml.ecdata_end = new EReg("\\]\\]>","");
Xml.edoctype_elt = new EReg("[\\[|\\]>]","");
Xml.ecomment_end = new EReg("-->","");
haxe.Timer.arr = new Array();
js.Lib.onerror = null;
RunTime.useGoogleUaAsLogViewer = true;
RunTime.urlIndex = "html5.html";
RunTime.urlZoom = "zoom.html";
RunTime.urlBookinfo = "./data/bookinfo.xml";
RunTime.urlPageInfo = "./data/pages.xml";
RunTime.urlHotlinks = "./data/hotlinks.xml";
RunTime.urlContents = "./data/contents.xml";
RunTime.urlSearch = "./data/search.xml";
RunTime.urlVideos = "./data/videos.xml";
RunTime.urlButtons = "./data/buttons.xml";
RunTime.searchHtmlCache = "";
RunTime.inputHtmlCache = "";
RunTime.book = new core.Book();
RunTime.bookTop = 0;
RunTime.bookBottom = 0;
RunTime.bookLeft = 0;
RunTime.bookRight = 0;
RunTime.pcode = "";
RunTime.bottomBarAlpha = 0.6;
RunTime.autoflipButtonUnselectedAlpha = 0.5;
RunTime.doubleClickIntervalMs = 300;
RunTime.key = "";
Zoom.imgSrc = "";
Zoom.pageNum = "";
Zoom.bookId = "";
Zoom.analyticsUA = "";
Zoom.bookTitle = "";
Zoom.bbv = "";
Zoom.pcode = "";
Zoom.hotlinks = [];
Zoom.videos = [];
Zoom.buttons = [];
Zoom.xOffset = 0;
Zoom.yOffset = 0;
Zoom.popupXOffset = 0;
Zoom.popupYOffset = 0;
Main.main()